InterviewLegend

Trees and Recursion

Alex Chen35 min readUpdated 86 real interview reports

Trees show up less at Lyft than graphs or intervals, but they still come up in phone screens, including two infrastructure screens a couple of months apart that asked the same question.

A third problem belongs with them even though it doesn't look like a tree problem at first. Nested data is a tree, and the solution is one function that checks the type of a value and calls itself on each child. Once you have that recursion right, all three problems follow the same pattern.

The two tree problems run in six languages, and the third runs in five, all but C++. Try the empty input on every one before you trust it.

LyftPremium lesson · Coding round

The 3 Lyft problems are below.

  1. A Premium questionCoding · Medium
  2. A Premium questionCoding · Medium
  3. A Premium questionCoding · Medium

Each with hints, the follow-up and a tested solution.

Get the Lyft questions

$49 a year · all 100 companies · cancel anytime

From 20,000+ candidate reports, forum threads behind logins and write-ups in Chinese.

Had your Lyft interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Lyft interview guide

Know what Lyft asks before you walk in.

28 coding · 2 system design · 12 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.