65: Valid Number


  • 0
    A

    I think the question can be best solved using Exception handling.
    Parse the string into a double and catch the exception. If you notice a NumberFormatException exception, just return false, otherwise true.

    The corner cases make the problem uninteresting, therefore, this should be marked as an easy problem. The corner cases should be removed as they are not clear from the question.


Log in to reply
 

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