r/programming • • Sep 22 '20

Google engineer breaks down the problems he uses when doing technical interviews. Lots of advice on algorithms and programming.

https://alexgolec.dev/google-interview-questions-deconstructed-the-knights-dialer/
6.4k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

5

u/SJC_hacker Sep 23 '20

They did build a lookup table for neighbors of a given digit. You can't use a lookup table for the entire solution because the length of the number is unbounded.

1

u/GolfSucks Sep 23 '20

You can though because it is bounded. After removing duplicates, there are 6 starting digits to consider (1 and 3 are the same). Then you check each N until those repeat (N = 13, gives the same result as N = 14).