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. css简单分页

    html代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <ti ...

  2. python yaml

    一.安装PyYAML http://pyyaml.org/ 二.入门参考 http://www.cnblogs.com/c9com/archive/2013/01/05/2845539.html ht ...

  3. iptables-save和iptables-restore

    iptables-save用来把当前的规则存入一个文件里以备iptables-restore使用.它的使用很简单,只有两个参数: iptables-save [-c] [-t table] 参数-c的 ...

  4. MYSQL 问题小总结

    mysql 问题小总结 1.MySQL远程连接ERROR 2003(HY000):Can't connect to MySQL server on ‘ip’(111)的问题 通常是mysql配置文件中 ...

  5. yii2学习网站

    1.http://tech.anruence.com/ 2.http://www.yiichina.com/doc/guide/2.0/input-multiple-models

  6. 着重基础之—Java 8 Comparator: How to Sort a List (List排序)

    着重基础之—Java 8 Comparator: How to Sort a List (List排序) 首先申明,这篇博客的内容不是我自己的知识,我是从国外网站搬来的,原因有二:1是因为大天朝对网络 ...

  7. EXCEL 单元格引用问题

    =(SUM(INDIRECT("'2.5酒店预订收入'!"&"J"&MATCH(C21,'2.5酒店预订收入'!B:B,0)&" ...

  8. 编译hbase-1.2.3源代码

    目录 目录 1 1. 约定 1 2. 安装jdk 1 3. 安装maven 1 4. 网络配置 2 4.1. eclipse 3 4.2. maven 3 5. 从hbase官网下载源代码包: 4 6 ...

  9. PAT甲 1048. Find Coins (25) 2016-09-09 23:15 29人阅读 评论(0) 收藏

    1048. Find Coins (25) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva loves t ...

  10. SPOJ10606 BALNUM - Balanced Numbers(数位DP+状压)

    Balanced numbers have been used by mathematicians for centuries. A positive integer is considered a ...