Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.

Example 1:

Input: "aba"
Output: True

Example 2:

Input: "abca"
Output: True
Explanation: You could delete the character 'c'.

Note:

  1. The string will only contain lowercase characters a-z. The maximum length of the string is 50000.
class Solution {
public:
bool validPalindrome(string s) {
int i,j;
int si,sj;
int n=s.size();
int count=;
int way=;
for(i=,j=n-;i<j;i++,j--){
if(s[i]==s[j])
continue;
else{
if(way==){
return false;
}
if(way==){
way++;
i=si;
j=sj;
j++;
}
if(way==){
way++;
count=;
si=i;
sj=j;
i--;
}
}
}
return true;
}
};

(判断是否回文)

String-680. Valid Palindrome II的更多相关文章

  1. 680. Valid Palindrome II【easy】

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

  2. 【Leetcode_easy】680. Valid Palindrome II

    problem 680. Valid Palindrome II solution: 不理解判断函数中的节点的问题... class Solution { public: bool validPali ...

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

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

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

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

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

  7. LeetCode 680. Valid Palindrome II (验证回文字符串 Ⅱ)

    Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...

  8. 【LeetCode】680. Valid Palindrome II

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

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

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

  10. 680. Valid Palindrome II

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

随机推荐

  1. Object类中通用方法之:toString()方法

    1.Java所有的对象都是Object类的实例,都可以直接调用该类中定义的方法,这些方法称为通用方法 2.toString()方法即为Object类中定义的通用方法之一 3.平时我们如果在控制台直接打 ...

  2. 调用父类构造器:super

    import static java.lang.System.*; class Base{ public String name; public double weight; public Base( ...

  3. shiro + struts2 在action 中使用 shiro 注解 @requiresPermissions 报错: 方法找不到,类初始失败

    06:36:34,405 ERROR http-8084-2 dispatcher.Dispatcher:38 - Exception occurred during processing reque ...

  4. Python os.chmod

    os.chmod(path,mode) 这个方法应该很简单,只需要2个参数,一个是路径,一个是说明路径的模式,下面列出了这个用法中可以使用的一些常用的模式: stat.S_ISUID: Set use ...

  5. 前端之JavaScript笔记4

    一 按键事件 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  6. 2018.10.19 NOIP模拟 加密(模拟)

    传送门 直接按hashhashhash函数反着算回去就行了. 加法用exgcdexgcdexgcd,异或直接枚举二进制位. 代码

  7. Part 1 - Getting Started(1-3)

    https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1. ...

  8. 打包python为可执行文件时报错R6034解决方案

    R6034 指的是:”An application has made an attempt to load the C runtime library incorrectly. Please cont ...

  9. Event事件冒泡和事件捕获

    <!doctype html> <html lang="en"> <head> <meta charset="gb2312&qu ...

  10. log4j日志文件路径设置

    假设有如下标准化的目录结构: $HOME |-- log |-- conf |-- bin |-- lib |-- data jar包放在lib目录,启动脚本放在bin目录,日志文件放在log目录,配 ...