Google Interview Question for Dev Leads

Country: United States
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
of 1 vote

a2i is the string to integer in c:
- 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..)

- Chris January 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

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.

- LinkSausage January 05, 2017 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More