【Leetcode_easy】680. Valid Palindrome II
problem
solution:
不理解判断函数中的节点的问题。。。
class Solution {
public:
bool validPalindrome(string s) {
int left = , right = s.size()-;
while(left<right)
{
if(s[left]!=s[right])
{
return isValid(s, left, right-) || isValid(s, left+, right);//err..
}
left++;
right--;
}
return true;
}
bool isValid(string s, int left, int right)
{
while(left<right)
{
if(s[left]!=s[right]) return false;
left++;
right--;
}
return true;
}
};
参考
1. Leetcode_easy_680. Valid Palindrome II;
2. Grandyang;
3. C++ Easy to Understand Clear Explaination;
完
【Leetcode_easy】680. Valid Palindrome II的更多相关文章
- 【LeetCode】680. Valid Palindrome II
Difficulty:easy More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/valid-palindrome ...
- 【LeetCode】680. Valid Palindrome II 验证回文字符串 Ⅱ(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 思路来源 初版方案 进阶方案 日期 题目地址 ...
- 680. Valid Palindrome II【easy】
680. Valid Palindrome II[easy] Given a non-empty string s, you may delete at most one character. Jud ...
- 【LeetCode】125. Valid Palindrome
题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...
- [leetcode]680. Valid Palindrome II有效回文II(可至多删一原字符)
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...
- [LeetCode] 680. Valid Palindrome II 验证回文字符串 II
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...
- 【LeetCode】125. Valid Palindrome 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 列表生成式 正则表达式 双指针 日期 题目地址:https:/ ...
- 680. Valid Palindrome II【Easy】【双指针-可以删除一个字符,判断是否能构成回文字符串】
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...
- 680. Valid Palindrome II 对称字符串-可删字母版本
[抄题]: Given a non-empty string s, you may delete at most one character. Judge whether you can make i ...
随机推荐
- 微信H5支付时用户有微信分身停留5秒后未选择哪个微信分身,也未支付就被动回调到商户支付是否完成的页面
微信H5支付时用户有微信分身停留5秒后未选择哪个微信分身,也未支付就被动回调到商户支付是否完成的页面 微信支付中间页调起微信收银台后超过5秒 安卓H5支付设置了redirect_url后调起微信收银台 ...
- Git---报错:git Please move or remove them before you can merge 解决方案
场景: 当前在本地仓库lucky,因修改了123.txt的文件内容,需要将lucky分支push到远程Git库,在push前有其他的同事已删除了远程Git库中的123.txt文件.因此这时就产生了远程 ...
- ajax向服务器发出get和post请求
假设有个网站A,它有一个简单的输入用户名的页面,界面上有两个输入框,第一个输入框包含在一个form表单里用来实现form提交,第二个输入框是单独的.没有包含在form里,下面就用这两个输入框来学习下j ...
- HTML 007 链接
HTML 链接 HTML 使用超级链接与网络上的另一个文档相连.几乎可以在所有的网页中找到链接.点击链接可以从一张页面跳转到另一张页面. 尝试一下 - 实例 HTML 链接如何在HTML文档中创建链接 ...
- php面向对象之静态方法使用
什么是静态方法? 不是所有的变量和方法都要通过创建对象来调用.可以通过给变量和方法加上static关键字来直接调用.无锡大理石测量平台 调用静态成员的语法格式为: 关键字::静态成员 关键字可以是: ...
- 提高React组件的复用性
1. 使用props属性和组合 1. props.children 在需要自定义内容的地方渲染props.children function Dialog(props) { //通用组件 return ...
- Greenplum 如何直连segment节点
Greenplum 展开阅读全文 直连greenplum segment节点的方法, utility模式 : 使用这种方式,不与其他节点通讯,只操作当前节点.也没有数据分布的概念. 如果使用uti ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest
目录 Contest Info Solutions A. Copying Homework C. Even Path E. Songwriter G. Performance Review H. Tw ...
- [HNOI2004]L语言 字典树 记忆化搜索
[HNOI2004]L语言 字典树 记忆化搜索 给出\(n\)个字符串作为字典,询问\(m\)个字符串,求每个字符串最远能匹配(字典中的字符串)到的位置 容易想到使用字典树维护字典,然后又发现不能每步 ...
- 对list某个条件排序,并实现分页
package com.jcloud.aioc.api.controller.Test; import com.alibaba.fastjson.JSON; import org.apache.poi ...