MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / isPalindrome

Method isPalindrome

Java/palindrome-number.java:2–18  ·  view source on GitHub ↗
(int x)

Source from the content-addressed store, hash-verified

1class Solution {
2 public boolean isPalindrome(int x) {
3 String _x = x+""; // integer convert string
4 String rev = ""; // store reverse
5 int i = 0;
6 for(i = _x.length()-1; i>=0; i--){
7 rev += _x.charAt(i);
8 }
9
10 if(_x.compareTo(rev) == 0){
11 // correct
12 return true;
13 }
14 else{
15 return false;
16 }
17
18 }
19}

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected