680. Valid Palindrome II
static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
bool validPalindrome(string s)
{
int len=s.length();
int left=,right=len-;
while(left<right)
{
if(s[left]!=s[right])
return judgedor(left+,right,s)||judgedor(left,right-,s);
left++;
right--;
}
return true;
} bool judgedor(int l,int r,string &s)
{
while(l<r)
{
if(s[l++]!=s[r--])
return false;
}
return true;
}
};
两端指针,若字符不相等,则跳过左边或者右边继续判定
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/ 目录 题目描述 题目大意 解题方法 双指针 思路来源 初版方案 进阶方案 日期 题目地址 ...
- Python 解LeetCode:680. Valid Palindrome II
题目:给定一个字符串,在最多删除一个字符的情况下,判断这个字符串是不是回文字符串. 思路:回文字符串,第一想到的就是使用两个指针,前后各一个,当遇到前后字符不一致的时候,有两种情况,删除前面字符或者删 ...
随机推荐
- 【转】 UI自动化测试的关注点
我发现了,大家极度关心自动化测试,尤其是UI自动化测试,虽然现在作为专项测试,离开这些越来越远了,但总能遥想以前,我总能想起自己做nokia的WindowsLive的ui自动化,做web的自动化测试, ...
- 用户管理系统之class
接着上一篇博客继续往下总结,上一篇博客的地址:https://www.cnblogs.com/bainianminguo/p/9189324.html 我们开始吧 这里我们就需要先看下我们设计的数据库 ...
- Sqlserver的身份验证模式
1.服务器名称: . 在服务器名称这里,我们有以下几种选择来连接到本地: (1)默认的服务器名称:也就是电脑主机的名称 (2)".",“.”就表示主机. (3)localhost ...
- 比特币系列钱包的UTXO总结
1.通过比特币钱包的WalletNotify配置来处理 本钱包内的交易信息的 推送.BlockNotify数据更多,不适合交易所的监听
- 一位大牛整理的Python资源
Python基本安装: * http://www.python.org/ 官方标准Python开发包和支持环境,同时也是Python的官方网站: * http://www.activestate ...
- python 面向对象编程 之 单例模式
单例模式三种实现方式: 单例模式:单例模式是解决系统资源浪费的一种方案,是指一个类实例化后可以多次使用此对象. 单例模式应用场景:数据库操作.日志.后台打印 # settings.py# Host=' ...
- Oracle性能优化2- 依据场景选择技术
1.索引的坏处 索引可以加快查询效率,但是使用不当,会造成插入性能很低 drop table test1 purge; drop table test2 purge; drop table test3 ...
- c#特性attribute:(二)
日志 初始化 特性类里边构造函数里的属性,带参数不带参数的 ******特性是编译时是不加到il 中的,是加到metadata中 ,本身对程序运行没有影响,除非我们主动的读取和使用区供反射可以使用. ...
- devexpress之barManager 使用
这次我不想使用ribboncontrol 控件 作为窗口菜单栏,也不想用传统的那种字体的方式 标题栏 一.Bars 1. 把BarManager组件添加到窗体中后,会自动创建两个空的 bars: ...
- Spring 监听
Spring 中的事件监听的实现 这里我们不讨论事件监听的机制的原理,我们只讨论如何在项目中实现时间监听. spring的事件监听是基于观察者模式.设计开发中.如下类与接口是我们必须要使用的. App ...