The unpleasant Corner Cases - swchen1234/Algorithm GitHub Wiki

Overflow

163. Missing Ranges

Seems the only way is to consider INT_MAX explicitly. Waiting for more elegant solution.

Valid Number

Four Special Cases:

  • decimal => use boolean to represent whether has appeared or not
  • e => use boolean, also reset num to be false, since we are looking for digit again. (e.g. 3e+ is not valid).
  • +/- => only allowed at the beginning or after e immediately.
  • digit => use a num boolean to indicate a digit has appeared ** not special handling for 0 is required(e.g. 007 is valid).