Airbnb phone screen - Rejected, sharing the question for prep
Replies (5)
This is the first time I've seen this question written up for Airbnb. Appreciate it. Did they give you a code editor or just verbal/whiteboard?
CoderPad, real code. They wanted me to actually run it and test edge cases. Leading zeros tripped me up for a second since I initially typed integers instead of strings.
Got something similar at a different company, the filtering approach clicked pretty fast once I drew it out. The bulls+cows extension is where it gets gnarly since you have two signals to reconcile.
Thanks for sharing. The 10000 candidate enumeration approach is the standard greedy here. Did they care about minimizing expected queries vs worst case, or just any working solution?
They seemed fine with the greedy filter approach for the main problem. The worst-case question was a separate follow-up where I think they wanted me to reason about an upper bound. I gave a rough argument but couldn't nail the exact number.
How long was the phone screen? 45 mins? Wondering if there's time to actually implement and test the full thing plus all three follow-ups.
45 mins total. Main solution plus N-digit generalization took most of it. The worst-case and bulls+cows were more discussion-level, didn't have to code them out.
The worst-case bound question is tricky tbh. For 4 digits you can prove it in like 7-8 queries worst case with the greedy filter but showing it rigorously takes a bit. Sorry you didn't advance, their loss.