InterviewLegend

Trees & BSTs

Alex Chen30 min readUpdated 1,074 real interview reports

LinkedIn asks four tree problems often enough that each one is worth preparing on its own. Three are on its tagged list, and candidates mention them from both the phone screen and the onsite. The fourth has no LeetCode page. It comes up in senior and Staff onsites, and about half of that prompt is designing the node type yourself.

Most of the score in these rounds comes from the follow-ups. One problem starts on a binary search tree and then takes the ordering away. Another accepts an in-order traversal as a first answer, but candidates who stayed at O(n) after the interviewer asked for O(log n + k) got lean-hire verdicts. Write the base version so the next step fits on top without a rewrite.

The LinkedIn angle
Draw the tree before you touch a pointer. Two of these problems rewire nodes or graft whole branches, so the bugs sit in the order of the assignments. A three-node sketch with arrows, redrawn after each line, catches a lost child faster than rereading the code. Write complete code that compiles and dry-run it on that sketch. Some interviewers will run it, and the ones who don't will watch you trace.

LinkedInPremium lesson · Coding round

The 4 LinkedIn problems are below.

  1. A Premium questionCoding · Hard · Frequently asked
  2. A Premium questionCoding · Medium
  3. A Premium questionCoding · Medium

+ 1 more in this lesson

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

Get the LinkedIn questions

$49 a year · all 100 companies · cancel anytime

From 1,074 LinkedIn reports, forum threads behind logins and write-ups in Chinese.

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

Know what LinkedIn asks before you walk in.

28 coding · 5 system design · 26 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.