String-680. Valid Palindrome II
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:
- 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的更多相关文章
- 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_easy】680. Valid Palindrome II
problem 680. Valid Palindrome II solution: 不理解判断函数中的节点的问题... class Solution { public: bool validPali ...
- [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 ...
- 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 ...
- 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 ...
- 【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
static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...
随机推荐
- Java8 改进的匿名内部类:
1.匿名内部类适合创建那种只需要一次使用的类 2.匿名内部类定义格式: new 实现接口() | 父类构造器(实参列表){ //匿名内部类类体部分 } 3.从上面定义格式可以看出,匿名内部类必须实现一 ...
- Luogu 2154 [SDOI2009]虔诚的墓主人
弄了很久,状态很烂…… 首先发现可用的点一共只有$1e5$个,所以可以离散化坐标来方便计算. 发现对于一个空格,设它的上.下.左.右分别有$u, d, l, r$个点,它产生的贡献是$\binom{u ...
- MapReduce调优总结与拓展
本文为<hadoop技术内幕:深入解析MapReduce架构设计与实现原理>一书第9章<Hadoop性能调优>的总结. 图1 Hadoop层次结构图 从管理员角度进行调优 1. ...
- windows8.1 初体验
昨天装了Win8.1,Office2013 由于是英文版的,需要装一下中文语言包,然后就能使用自带的微软拼音输入法了. 我喜欢双屏时的桌面背景,选择span时一张图片可以跨越2个屏幕,比win7的好. ...
- 2018.09.19 atcoder Card Game for Three(组合数学)
传送门 简单组合数学想优化想了半天啊233. 我们只需考虑翻开n张A,b张B,c张C且最后一张为A的选法数. 显然还剩下m+k−b−cm+k-b-cm+k−b−c张牌没有选. 这样的话无论前n+b+c ...
- Yii框架请求
$request = Yii::$app->request; $get = $request->get(); // 等价于: $get = $_GET; $id = $request-&g ...
- hdu-1877(大数+进制转换)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1877 思路:注意考虑0,0的情况. #include<iostream> #include ...
- EXCEL 单元格引用问题
=(SUM(INDIRECT("'2.5酒店预订收入'!"&"J"&MATCH(C21,'2.5酒店预订收入'!B:B,0)&" ...
- (最小生成树) Networking -- POJ -- 1287
链接: http://poj.org/problem?id=1287 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7494 ...
- 配置使用sourcemap调试vue源码爬坑
环境: Google Chrome V72.0.3626.109 vue-dev V 2.6.10 爬坑的乐趣就不说了(我恨啊),以下说一下出坑要点 1. 在vue-dev的package.json ...