Beats 99% submissions


  • 0
    S
    public class Solution {
        public bool IsPalindrome(int x) {
             int y = Reverse(x);
             if(x == y)
                return true;
             else 
                return false;
        }
        
        int Reverse(int x)
        {
            int y = 0;
            while(x > 0)
            {
                y = (y * 10) + (x % 10); 
                x /= 10;
            }
            return y;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.