Java solution


  • 0
    P
    class Solution {
        public boolean isNumber(String s) {
            try {
                Double test1 = Double.valueOf(s);
                if(test1!=null && !(s.endsWith("f")||s.endsWith("D")) )
                    return true;
                else
                    return false;
            } catch (Exception e) {
                return false;
            }
        }
    }```

Log in to reply
 

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