Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3352279

Browse files
authored
Create 0680-valid-palindrome-ii.kt
1 parent02adefc commit3352279

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎kotlin/0680-valid-palindrome-ii.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
classSolution {
2+
funvalidPalindrome(s:String):Boolean {
3+
4+
var left=0
5+
var right= s.lastIndex
6+
7+
while (left<= right) {
8+
if(s[left]!= s[right])
9+
return isValid(s, left, right-1)|| isValid(s, left+1, right)
10+
left++
11+
right--
12+
}
13+
14+
returntrue
15+
}
16+
17+
privatefunisValid(s:String,_left:Int,_right:Int):Boolean {
18+
19+
var left=_left
20+
var right=_right
21+
22+
while (left<= right) {
23+
if(s[left]!= s[right])
24+
returnfalse
25+
left++
26+
right--
27+
}
28+
29+
returntrue
30+
}
31+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp