알고리즘
[LeetCode] Palindrome Number
개발정리
2021. 6. 22. 00:19
class Solution {
public boolean isPalindrome(int x) {
if (x < 0) {
return false;
}
String strX = String.valueOf(x);
String reverseX = String.valueOf(x);
String tmp = "";
for(int i=reverseX.length()-1; i>=0; i--) {
tmp += reverseX.charAt(i);
}
if (tmp.equals(strX)) {
return true;
} else {
return false;
}
}
}
Palindrome Number - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com