passed for opportunistic reasons


  • 0
    G

    to tell the truth,i dont know what the extra space mean.no other parameters? no other type of variables?or in limited space? if someone can tell me,thanks so much!
    and the follow code passed for some opportunistic reasons like try{}catch{}.

    public class Solution {

     public boolean isPalindrome(int x) {
        if(x < 0) return false;
        try{
            if(x == palindrome(x)) return true;
            else return false;
        }catch(Exception e){
            return false;
        }
    }
    
    public int palindrome(int x){
        int y = 0;
        while(x % 10 >= 0 && x > 0){
            y  =  y * 10 + x % 10;
            x = x / 10;
        }
        return y;
    }
    

    }


Log in to reply
 

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