728x90
반응형
Python
class Solution:
def isPalindrome(self, x: int) -> bool:
str_x = str(x)
if str_x == str_x[::-1]:
return True
return False
Java
class Solution {
public boolean isPalindrome(int x) {
String str_x = Integer.toString(x);
if ((new StringBuilder(str_x)).reverse().toString().equals(str_x)) {
return true;
}
return false;
}
}
728x90
반응형
'LeetCode > Easy' 카테고리의 다른 글
112. Path Sum (0) | 2022.03.25 |
---|---|
182. Duplicate Emails (0) | 2022.03.24 |
69. Sqrt(x) (0) | 2022.03.20 |
937. Reorder Data in Log Files (0) | 2022.01.23 |
680. Valid Palindrome II (0) | 2022.01.16 |