코딩테스트
[LeetCode] Valid Palindrome
gajy
2022. 3. 31. 22:33
728x90
https://leetcode.com/problems/valid-palindrome/
class Solution {
public boolean isPalindrome(String s) {
s = s.toLowerCase().replaceAll("[^a-z0-9]", "");
for(int i = 0; i < s.length()/2; i++) {
if(s.charAt(i) != s.charAt(s.length()-1-i)){
return false;
}
}
return true;
}
}
728x90