当前位置:网站首页>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;
}
}
}
边栏推荐
- c#网页打开winform exe
- Three methods of script about login and cookies
- Zhuhai's waste gas treatment scheme was exposed
- Docker compose配置MySQL并实现远程连接
- MATLB | real time opportunity constrained decision making and its application in power system
- Convert binary search tree into cumulative tree (reverse middle order traversal)
- Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...
- The inconsistency between the versions of dynamic library and static library will lead to bugs
- Code review concerns
- Zhuhai laboratory ventilation system construction and installation instructions
猜你喜欢

Four dimensional matrix, flip (including mirror image), rotation, world coordinates and local coordinates

Five challenges of ads-npu chip architecture design

BiShe - College Student Association Management System Based on SSM

Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition

MATLB | real time opportunity constrained decision making and its application in power system

How to extract MP3 audio from MP4 video files?

037 PHP login, registration, message, personal Center Design

Hcip---ipv6 experiment

Dedecms plug-in free SEO plug-in summary

一图看懂!为什么学校教了你Coding但还是不会的原因...
随机推荐
2022年广西自治区中职组“网络空间安全”赛题及赛题解析(超详细)
IP storage and query in MySQL
Loop structure of program (for loop)
MYSQL---查询成绩为前5名的学生
How to get the PHP version- How to get the PHP Version?
What is the most suitable book for programmers to engage in open source?
FFT 学习笔记(自认为详细)
伦敦银走势中的假突破
How to extract MP3 audio from MP4 video files?
Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
Leetcode 208. 实现 Trie (前缀树)
037 PHP login, registration, message, personal Center Design
Netease smart enterprises enter the market against the trend, and there is a new possibility for game industrialization
Is chaozhaojin safe? Will it lose its principal
基於DVWA的文件上傳漏洞測試
Unity | 实现面部驱动的两种方式
直播系统代码,自定义软键盘样式:字母、数字、标点三种切换
ThreeDPoseTracker项目解析
Obstacle detection
Vulhub vulnerability recurrence 75_ XStream