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. 纯净版Windows7系统迅雷下载路径

    windows 7 旗舰版64位------------------- Windows 7 Ultimate (x64) - DVD (Chinese-Simplified) 详细信息 文件名     ...

  2. 模板练习(LUOGU)

    1:并查集 P3183食物链 #define man 300050 ; int find(int x){ if(fa[x]==x) return fa[x]; return fa[x]=find(fa ...

  3. tp5允许跨域

    header("Access-Control-Allow-Origin: *"); 放在命名空间之后

  4. 查询yum包安装路径

    rpm -ql php71-php yum install json yum install libcurl

  5. jquery插件解读之tabs

    先上代码,符简略关键性说明: /** * jQuery EasyUI 1.4.1 *  * Copyright (c) 2009-2014 www.jeasyui.com. All rights re ...

  6. IE10中KendoUI treeview 点击后出现虚线框的解决方案

    在head中添加:<meta http-equiv="X-UA-Compatible" content="IE=edge"> 修改渲染模式即可.

  7. 2018.09.16 loj#10241. 取石子游戏 1(博弈论)

    传送门 好像是某年的初赛题啊. 有个很显然的结论. 当n" role="presentation" style="position: relative;&quo ...

  8. 着重基础之—构建工具—Maven的依赖管理

    着重基础之—构建工具—Maven的依赖管理 项目构建利器Maven给我们开发人员带来了极大的便利,从繁琐的jar包管理中脱身的程序员终于可以有时间再进入另一个坑了. 我今天要给大家分享的内容是我在实际 ...

  9. js 获取时间不能大于当前系统时间

    var dataDate=$.trim($("#dataDate").val()); if(dataDate.length==0){ $("#dataDateTip&qu ...

  10. Unit Testing of Spring MVC Controllers1

    我们的pom.xml文件相关的部分看起来如下: <dependency>    <groupId>com.fasterxml.jackson.core</groupId& ...