NewThe Learning module is now liveSee what's new
avatar
User-20ureOct 10, 2026

Airbnb phone screen, the 2D iterator with remove

Interview Experiences
airbnb

Airbnb phone screen, the 2D iterator with remove

Had my Airbnb phone screen Tuesday. One question, 45 min, interviewer pasted the prompt and we started coding pretty much right away.

You get a list of lists of ints and build an iterator over it with hasNext, next and remove. remove deletes whatever the last next() returned, and it has to delete it from the actual underlying lists, not a copy. Some inner lists can be empty, sometimes a few in a row.

I kept two indices, row and col. hasNext skips past empty rows and has to be safe to call multiple times without moving anything, which I didn't think about until he called it like three times back to back in his test. remove is where most of my time went tbh. After you pop the element, the next value shifts into the slot you're pointing at, so if you already advanced col you skip it. I ended up tracking where the last returned element was separately and fixing col after the delete. Calling remove twice without a next in between should throw too.

Wrote my own tests at the end, he asked for complexity, finished with maybe 5 min left.

Recruiter emailed two days later, moving to onsite. Anyone know if the onsite still has the code review round?

19173k

Replies (4)

avatar
User-kgor9Oct 10, 2026

my loop earlier this year had a code review round, 3 PRs and you leave comments. not sure if it's every team though

98
avatar
nehadesai1203Oct 10, 2026

oh nice, did they care more about bugs or style stuff?

103
avatar
User-kgor9Oct 10, 2026

Reply to @nehadesai1203mostly bugs and edge cases from what I remember, some naming comments too

11
avatar
User-39e5aOct 11, 2026

congrats on moving forward, good luck on the onsite

52
avatar
User-izsxzOct 10, 2026

what language did you use? feels like this one is way more annoying in java with the list mutation

48
avatar
nehadesai1203Oct 10, 2026

python. honestly that made the remove part easier since I could just del from the inner list

72
avatar
User-je75mOct 10, 2026

I had the text box formatting one for my screen. the wrapping wasn't hard but the spacing rules took me forever to get right

18
No more replies