InterviewLegend

Caching & Precomputation

Alex Chen34 min readUpdated 1,074 real interview reports

Many of LinkedIn's class problems give the constructor a dataset and then query it many times. One gives you a fixed list of known words, and another gives you a tokenized job posting. When candidates get rejected on the first one, the feedback names a precomputation they skipped. Do that work in the constructor. Then each query after it can be a lookup or a short merge, which is what the interviewer is waiting to see.

The other two are different. They keep state that changes as you go. One draws a member at random, weighted by ticket count, while tickets are added and removed, all in O(1) average time. The other is a cache that evicts by a rank the caller owns. Its follow-up usually makes it thread-safe and asks you to name the race condition behind every lock. Both build on the Data Structure Design lesson and reuse its pairing of a hash map with a second structure.

The LinkedIn angle
Say where the cost goes before you write a method. Put a number on the constructor and a number on each query. "One pass to build the map, then one lookup per query" settles the word problem before any code, and it keeps you away from the backtracking that has led to rejections. Then say what an update costs, since the follow-ups here tend to add add, remove or an uneven input once the base version works.

LinkedInPremium lesson · Coding round

The 4 LinkedIn problems are below.

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

+ 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.