当前位置:网站首页>Leetcode skimming questions_ Verify palindrome string II
Leetcode skimming questions_ Verify palindrome string II
2022-07-06 01:24:00 【Figure throne】
Title Description

Java resolvent
class Solution {
public boolean Palindrome(String s, int start, int end)
{
while(start < end)
{
if(s.charAt(start) == s.charAt(end))
{
start++;
end--;
}
else
{
return false;
}
}
return true;
}
public boolean validPalindrome(String s) {
int start = 0;
int end = s.length() - 1;
while(start < end)
{
if(s.charAt(start) == s.charAt(end))
{
start++;
end--;
}
else
{
break;
}
}
if(start >= end)
{
return true;
}
else
{
boolean valid1 = Palindrome(s, start + 1, end);
boolean valid2 = Palindrome(s, start, end - 1);
if(valid1 || valid2)
{
return true;
}
else
{
return false;
}
}
}
}
C resolvent
bool Palindrome(char * s, int start, int end)
{
while(start < end)
{
if(s[start] == s[end])
{
start++;
end--;
}
else
{
return false;
}
}
return true;
}
bool validPalindrome(char * s){
bool valid1;
bool valid2;
int start = 0;
int end = strlen(s) - 1;
while(start < end)
{
if(s[start] == s[end])
{
start++;
end--;
}
else
{
break;
}
}
if(start >= end)
{
return true;
}
else
{
valid1 = Palindrome(s, start + 1, end);
valid2 = Palindrome(s, start, end - 1);
if(valid1 || valid2)
{
return true;
}
else
{
return false;
}
}
}
边栏推荐
- Remember that a version of @nestjs/typeorm^8.1.4 cannot be obtained Env option problem
- Introduction to robotics I. spatial transformation (1) posture, transformation
- Interview must brush algorithm top101 backtracking article top34
- Leetcode1961. 检查字符串是否为数组前缀
- Superfluid_ HQ hacked analysis
- Basic process and testing idea of interface automation
- PHP error what is an error?
- Ubantu check cudnn and CUDA versions
- ORA-00030
- Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks
猜你喜欢

Condition and AQS principle

Installation and use of esxi

About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)

Threedposetracker project resolution

Unity | 实现面部驱动的两种方式

Basic process and testing idea of interface automation

A picture to understand! Why did the school teach you coding but still not

WordPress collection plug-in automatically collects fake original free plug-ins
![[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。](/img/3c/ec97abfabecb3f0c821beb6cfe2983.jpg)
[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。

Recoverable fuse characteristic test
随机推荐
037 PHP login, registration, message, personal Center Design
282. Stone consolidation (interval DP)
Idea sets the default line break for global newly created files
internship:项目代码所涉及陌生注解及其作用
Redis' cache penetration, cache breakdown, cache avalanche
MYSQL---查询成绩为前5名的学生
FFT learning notes (I think it is detailed)
Unity VR resource flash surface in scene
Nmap: network detection tool and security / port scanner
1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once
leetcode刷题_平方数之和
A glimpse of spir-v
SPIR-V初窺
MATLB | real time opportunity constrained decision making and its application in power system
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
WordPress collection plug-in automatically collects fake original free plug-ins
The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
记一个 @nestjs/typeorm^8.1.4 版本不能获取.env选项问题
c#网页打开winform exe
Convert binary search tree into cumulative tree (reverse middle order traversal)