My concise Java solution


  • 0
    Z
    public class Solution {
    public boolean isPalindrome(String s) {
        int l = s.length()-1; int i = 0;
        while(i<l){
            while(Character.getNumericValue(s.charAt(i))>35 || Character.getNumericValue(s.charAt(i))<0 &&i<l)
            i++;
            while(Character.getNumericValue(s.charAt(l))>35 || Character.getNumericValue(s.charAt(l))<0 &&l>i)
            l--;
            if(Character.getNumericValue(s.charAt(i)) != Character.getNumericValue(s.charAt(l)))
            return false;
            i++;
            l--;
        }
        return true;
    }
    

    }


Log in to reply
 

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