File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 11package leetcode_study
22
3- class Solution {
3+ class SolutionContainsDuplicate {
44 fun containsDuplicate (nums : IntArray ): Boolean {
55 val size = nums.size
66 val numsToSet = nums.toSet()
77
88 return size != numsToSet.size
99 }
10- }
10+ }
Original file line number Diff line number Diff line change 1+ package leetcode_study
2+
3+ class SolutionValidPalindrome {
4+ fun isPalindrome (s : String ): Boolean {
5+ val sToCharArray = s.toCharArray()
6+ var startIndex = 0
7+ var endIndex = sToCharArray.size - 1
8+ while (startIndex < endIndex) {
9+ if (! sToCharArray[startIndex].isLetterOrDigit() || sToCharArray[startIndex].isWhitespace()) {
10+ startIndex++
11+ continue
12+ }
13+ if (! sToCharArray[endIndex].isLetterOrDigit() || sToCharArray[endIndex].isWhitespace()) {
14+ endIndex--
15+ continue
16+ }
17+ if (sToCharArray[startIndex].lowercase() == sToCharArray[endIndex].lowercase()) {
18+ startIndex++
19+ endIndex--
20+ } else {
21+ return false
22+ }
23+ }
24+
25+ return true
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments