My simple Java solution


  • -1
    7

    public class Solution {

    public boolean isNumber(String s) {
        boolean res=true;
        char c=s.charAt(s.length()-1);
        try{
            Double.valueOf(s);
        }
        catch(NumberFormatException e ){
            res=false;
        }
        finally{
            if(c=='f'||c=='d'||c=='D'||c=='F')
                res=false;
            return res;
        }
    }
    

    }


Log in to reply
 

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