Google Interview Question
Dev LeadsCountry: United States
Interview Type: In-Person
You missed "-" "+" (+1 is OK but + is not integer)
Most of the cases you raised are correct except they are of the same pattern (i.e. none [0-9] after first char)
The interviewer was pretty peculiar about NULL vs. empty string. I said check input in the beginning but he dismissed NULL outright ("that is an application level error"). Then reminded me of checking empty string.
a2i is the string to integer in c:
- Chris January 04, 2017- overflow depending on integer size of that machine, e.g. max and min of integer
- two "--" like "--1234"
- "123-32"
- decimal "." or "," or "..", or ",,"
- thousand seperators, depending on cultural settings (e.g. . or ' ...)
- what surounds the integer, spaces, end of string, other characters like "124zoo"
- whitespaces at the beginning, which of them
- only base 10, or octal, binary, hex with suffix, prefix
- white spaces, like line breaks, back spaces in between
- encodings, like utf8 etc...
- special characters like chinese, japanese (ichi, ni, etc..)
...