My java solution


  • 0
    1
    public boolean isNumber(String s) {
        s = s.trim();
        try {
            double a = Double.parseDouble(s);
        } catch (NumberFormatException e) {
            return false;
        }
        if(s.substring(s.length()-1,s.length()).equals("f")||
                s.substring(s.length()-1,s.length()).equals("F")||
                s.substring(s.length()-1,s.length()).equals("d")||
                s.substring(s.length()-1,s.length()).equals("D")
                )
            return false;
        return true;
    

    }


Log in to reply
 

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