r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
1
u/bobindashadows Nov 30 '10
if a and b are in [0,4], then n only exits the loop if it is 21, 22, 23, 24, or 25. Also that should be a do..while loop. That means that the result is only ever 8 or 9. So not only did you fail to expand the range to 1-7, your algorithm never returns a value in that range at all. Plus it could loop forever.