problem

680. Valid Palindrome II

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的更多相关文章

  1. 【LeetCode】680. Valid Palindrome II

    Difficulty:easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/valid-palindrome ...

  2. 【LeetCode】680. Valid Palindrome II 验证回文字符串 Ⅱ(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 思路来源 初版方案 进阶方案 日期 题目地址 ...

  3. 680. Valid Palindrome II【easy】

    680. Valid Palindrome II[easy] Given a non-empty string s, you may delete at most one character. Jud ...

  4. 【LeetCode】125. Valid Palindrome

    题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...

  5. [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 ...

  6. [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 ...

  7. 【LeetCode】125. Valid Palindrome 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 列表生成式 正则表达式 双指针 日期 题目地址:https:/ ...

  8. 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 ...

  9. 680. Valid Palindrome II 对称字符串-可删字母版本

    [抄题]: Given a non-empty string s, you may delete at most one character. Judge whether you can make i ...

随机推荐

  1. Linux下安装nginx实现伪分布

    1.安装 Nginx 的编译环境 gcc yum install gcc-c++ 2.nginx 的 http 模块使用 pcre 解析正则表达式,所以安装 perl 兼容的正则表达式库 yum in ...

  2. jQuery toast 淡入淡出提示

    #toast{ position: fixed; top: 44%;left:50%;transform: translateX(-50%); min-width: 80px; max-width: ...

  3. electron中引入jquery

    <!-- Insert this line above script imports --> <script>if (typeof module === 'object') { ...

  4. RMQ问题【模板】

    概念 RMQ 是英文 Range Maximum/Minimum Query 的缩写,表示区间最大(最小)值. 解决 RMQ 问题的主要方法有两种,分别是 ST 表和线段树.本文主要讲 ST 表. S ...

  5. 用免费的webservice查询天气

    亲测能用URL地址:https://blog.csdn.net/qq_37171353/article/details/79415960 wsimport -s . file:///D:weath.w ...

  6. Apache的安装和配置

    一.官网下载Apache 官网地址:https://httpd.apache.org/ 点击Download--->点击Files for Microsoft Windows--->点击A ...

  7. 如何安全的从LVM中移除磁盘

        学习如何安全的从LVM中移除磁盘,当磁盘卷中有磁盘出现问题或是想把磁盘卷中的磁盘重新使用时就显得十分有用.本教程将重点关注以下问题: 如何安全的从LVM中移除磁盘 如何联机从VG中移除磁盘 如 ...

  8. LOJ2541. 「PKUWC2018」猎人杀 [概率,分治NTT]

    传送门 思路 好一个神仙题qwq 首先,发现由于一个人死之后分母会变,非常麻烦,考虑用某种方法定住分母. 我们稍微改一改游戏规则:一个人被打死时只打个标记,并不移走,也就是说可以被打多次但只算一次.容 ...

  9. ubuntu中编译安装gcc 9.2.0

    一切都和其他源码安装软件是一样的: 一.下载源代码: http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz 二.解压文件 tar xvf gcc- ...

  10. GC和GC分配策略

    一.内存如何回收 解决如何回收问题,首先需要解决回收对象的问题?什么样的对象需要回收,怎么样的不需要回收?保证有引用的内存不被释放:回收没有指针引用的内存是Collector的职责,在保证没有指针引用 ...