MCPcopy Index your code
hub / github.com/Blankj/awesome-java-leetcode / isPalindrome

Method isPalindrome

src/com/blankj/easy/_0009/Solution.java:22–30  ·  view source on GitHub ↗
(int x)

Source from the content-addressed store, hash-verified

20// }
21
22 public boolean isPalindrome(int x) {
23 if (x < 0 || (x != 0 && x % 10 == 0)) return false;
24 int halfReverseX = 0;
25 while (x > halfReverseX) {
26 halfReverseX = halfReverseX * 10 + x % 10;
27 x /= 10;
28 }
29 return halfReverseX == x || halfReverseX / 10 == x;
30 }
31
32 public static void main(String[] args) {
33 Solution solution = new Solution();

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected