【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 ...
随机推荐
- vue 自定义全局组件
- MongoDB 分片管理(四)数据均衡
通常来说,MongoDB会自动处理数据均衡. 1.1 集群分片的块的均衡 注意,均衡器只使用块的数量,而非数据大小,来作为衡量分片间是否均衡的指标. 1.2 均衡器 1.执行所有数据库管理操作前,都应 ...
- jsp利用webuploader实现超大文件分片上传、断点续传
1,项目调研 因为需要研究下断点上传的问题.找了很久终于找到一个比较好的项目. 在GoogleCode上面,代码弄下来超级不方便,还是配置hosts才好,把代码重新上传到了github上面. http ...
- pyCharm专业版破解方案【附:四种破解】
前言: 一般适合我们的工具才是好的工具,通过调研对比发现pycharm还不错,其它工具就不一一列举了 pyCharm社区版可以永久免费,但是它不支持HTML, JS, and SQL等,为了方便以后使 ...
- Mac 解决终端:-bash: /Users/xxx/.profile: No such file or directory
touch ~/.profile加入export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin 参考:https://www.zhihu.com/ ...
- java中int 和String相互转换
一.String转为int int i=Integer.parseInt(string):int i=Integer.valueOf(s).intValue(); 二.int转为String Stri ...
- Linux常用命令大全(最完整)
要学习Linux语法最好到专门的网站 常用语法大全:https://www.runoob.com/linux/linux-command-manual.html (菜鸟教程) 另外提供一个总结的不错的 ...
- [提权]CVE-2018-8120漏洞复现
0x01 漏洞名称 Windows操作系统Win32k的内核提权漏洞 0x02 漏洞编号 CVE-2018-8120 0x03 漏洞描述 部分版本Windows系统win32k.sys组件的NtUse ...
- OpenFOAM的PISO算法【转载】
转载自:http://openfoam.blog.sohu.com/94234375.html 流体力学的控制方程是耦合方程组,形式上体现为连续方程和运动方程的耦合,变量上体现为速度和压强的耦合.在数 ...
- C#MD5方法
不同形式,一样结果 /// <summary> /// 获取大写的MD5签名结果 /// </summary> /// <param name="encypSt ...