DevsUnite

LinkedIn Interview Questions

32 real coding interview questions recently asked at LinkedIn, spanning Data Structure Design, Trees and Graphs and Arrays and DP, with a real difficulty tag and a direct LeetCode link for every question.

By DevsUnite · 32 Problems

Total Problems: 32Difficulty Levels:EasyMediumHard

Loading your progress…0/32
Nested List Weight Sum
LeetCodeMedium

Given a nested list of integers (lists can contain integers or further nested lists), compute the sum of all integers weighted by their depth of nesting. It's solved with straightforward recursive DFS, passing down the current depth and multiplying each integer found by it. It's a simpler recursion/tree-traversal-style problem, good for verifying comfort with recursive structures that aren't literal trees.

Nested List Weight Sum II
LeetCodeMedium

A variant of Nested List Weight Sum where the weighting is inverted: integers at shallower depth get a higher weight (weight = maxDepth - depth + 1) instead of a lower one. Since max depth isn't known in advance, an efficient one-pass solution tracks a running "unweighted" total across depths and adds it cumulatively at each level, avoiding the need for two full passes (one to find max depth, one to sum). It's a good follow-up to the original problem that tests whether a candidate can adapt a straightforward recursive solution when the weighting direction flips.

Max Stack
LeetCodeHard

A design problem asking for a stack that supports push, pop, top, peekMax, and popMax — the difficulty is popMax, which must remove the maximum element from anywhere in the stack while preserving relative order of the rest. Efficient solutions typically pair a doubly linked list (for O(1) removal from the middle) with an ordered map or balanced structure keyed by value to locate the max quickly. It's a strong test of composing multiple data structures to hit better-than-O(n) time on every operation, not just the easy ones.

All O'one Data Structure
LeetCodeHard

This design problem requires inc(key), dec(key), getMaxKey(), and getMinKey() to all run in O(1) — ruling out a plain hashmap plus heap, since heaps don't give O(1) max/min removal alongside arbitrary key updates. The standard solution buckets keys by their current count in a doubly linked list of count-buckets, combined with a hashmap from key to its bucket, so incrementing or decrementing a key just moves it to an adjacent bucket. It's a genuinely hard composition of a hash map with a linked structure, and a strong signal for whether a candidate can design toward a strict complexity bound rather than a merely-workable one.

Shortest Word Distance II
LeetCodeMedium

A design problem: given a list of words with repeats, preprocess it so that many subsequent queries for the shortest distance between two given words can each be answered efficiently. The solution precomputes a hash map from each word to a sorted list of its indices, then answers each query with a two-pointer merge over the two words' index lists to find the minimum gap. It tests the ability to separate one-time preprocessing cost from per-query cost when a query is expected to run many times, unlike the single-query version of this problem.

Design Add and Search Words Data Structure
LeetCodeMedium

A design problem: build a data structure supporting adding words and searching with a wildcard '.' that can match any single letter. It tests whether a candidate can extend a trie with DFS-based search that branches over all children when a wildcard is encountered, rather than requiring an exact-match traversal. It's a natural harder follow-up to the basic Trie problem and checks whether a candidate can adapt a known structure to a new requirement.

Insert Delete GetRandom O(1)
LeetCodeMedium

This design problem requires insert, remove, and getRandom to all run in O(1) average time, which rules out a plain hash set (no O(1) random access) or a plain array (no O(1) removal by value). The standard solution pairs an array (for O(1) indexed random access) with a hash map from value to array index, and handles removal by swapping the target element with the last array element before popping, keeping the array dense. It tests whether a candidate can identify which single data structure fails which requirement and combine two structures to satisfy all three simultaneously.

LFU Cache
LeetCodeHard

A harder relative of LRU Cache: eviction is based on least frequency of use (with least-recently-used as a tiebreaker), requiring O(1) get and put. The standard solution uses a hash map from key to value/frequency plus a second structure — typically frequency buckets implemented as doubly linked lists, tracked with a pointer to the current minimum frequency — to keep every operation O(1). This is a genuinely advanced caching pattern relevant to systems needing usage-aware eviction beyond simple recency, which is why it appears in interview loops as a step up from LRU Cache once a candidate has demonstrated that baseline.

Insert Delete GetRandom O(1) - Duplicates allowed
LeetCodeHard

Design a data structure supporting insert, remove, and getRandom (returning a uniformly random existing element) all in average O(1) time, where the same value may be inserted multiple times. The solution pairs a dynamic array (for O(1) random access by index) with a hash map from value to the set of indices where it currently appears, using a swap-with-last-element trick on removal to keep the array compact. It's a step up from the no-duplicates version of this problem and tests careful bookkeeping when multiple indices must be tracked per value.

Design Authentication Manager
LeetCodeMedium

Design a system that issues time-limited authentication tokens, supports renewing an unexpired token's expiration, and can count how many tokens are currently unexpired at a given time. A straightforward solution uses a hash map from token ID to its expiration time, removing or ignoring expired entries as needed; countUnexpiredTokens can be implemented directly by scanning the map. It's a design problem focused on correctly modeling time-based expiration and renewal semantics rather than requiring an advanced algorithm.

Serialize and Deserialize BST
LeetCodeMedium

You need to encode a binary search tree into a string and decode that string back into an identical tree. Because it's specifically a BST (not just any binary tree), a preorder traversal alone is enough to reconstruct the tree unambiguously — the decode step rebuilds it by recursively partitioning the preorder sequence using each value's implied lower/upper bounds, without needing explicit null markers the way the general binary-tree version of this problem does. It's a good test of whether a candidate exploits the BST ordering property to produce a more compact and efficient solution than the general-tree case.

Log in to save your progress, favorites, and notes to your account.

Frequently asked questions

What coding interview questions does LinkedIn ask?

This page tracks 32 real, recently reported LinkedIn coding interview questions, organized by topic: Data Structure Design, Trees and Graphs and Arrays and DP.

How many LinkedIn interview questions are on this list?

32 questions in total: 5 Easy, 20 Medium, and 7 Hard, each linked to its real LeetCode problem page.

Is it free to use?

Yes. Browsing every problem on this page is completely free, with no account required. Creating a free DevsUnite account lets you save your checked-off progress, star favorites, and add personal notes that sync across devices.

Do I need an account to track my progress?

You can read and solve every problem without logging in. An account is only required to mark a problem as done, star it, or add a note. Those actions save to your account instead of resetting on refresh.