25 minutes
Given an integer x, return true if x is a palindrome, and false otherwise.
(-2 31 ) < n < (2 31 - 1)
class Solution {
public boolean isPalindrome(int x) {
if(x < 0) return false;
StringBuilder stringBuilder = new StringBuilder(Integer.toString(x));
return stringBuilder.toString().contentEquals(stringBuilder.reverse());
}
}
N / A