LinkedIn logo

LinkedIn Software Engineer System Design Questions

48 practice questions for LinkedIn Software Engineer interviews

LinkedIn software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for LinkedIn.

system design Hard caching #1

1. Design MemberProfileCache — a bounded LRU cache with per-entry expiration


Background
LinkedIn surfaces member profile summaries in search results, connection suggestions, and messaging. Model an in-process cache of serialized profile-summary projections so repeated reads avoid fetching the projection again, while per-entry expiration bounds how long an old projection remains cached. This exercise adapts a reported LinkedIn LRU-with-TTL interview question; it does not claim to reproduce LinkedIn's production implementation.
Requirements
1. Construct a cache with a positive entry capacity. Each entry maps a positive member ID to a serialized profile-summary string; a missing or expired entry returns null.
2. Every operation receives an explicit integer now_ms. Times across all calls must be nondecreasing. An entry written at time t with TTL d expires at t + d, and is unavailable when now_ms >= t + d.
3. Before performing any operation, remove all expired entries. put inserts or replaces an entry, resets its TTL, and makes it most recently used. A successful get also makes an entry most recently used but does not extend its TTL. Other operations do not change recency.
4. If inserting an entry would exceed capacity after expiration cleanup, evict the least recently used live entry. Replacing an existing member must not evict another live entry. Old expiration records must never delete a newer replacement.
5. cleanup returns the number of currently stored entries it expires during that call, excluding previously evicted or replaced versions. size returns the number of live entries after cleanup.
6. Avoid scanning every live entry on every operation. Maintain O(capacity) storage, including expiration metadata; amortized occasional rebuilding of metadata is allowed. Implement a single-threaded class, not a distributed architecture.
Class API
  • MemberProfileCache(capacity: int) — create an empty cache with the specified entry limit.

  • get(member_id: int, now_ms: int) -> Optional[str] — return a live summary and update recency, or return null.

  • put(member_id: int, summary: str, ttl_ms: int, now_ms: int) -> None — write a summary, reset its expiration, and enforce capacity.

  • cleanup(now_ms: int) -> int — remove expired entries and return the number removed by this call.

  • size(now_ms: int) -> int — return the number of live entries.


Example 1:
Input sequence:
[
  ["MemberProfileCache", [2]],
  ["put", [101, "Ada", 10, 0]],
  ["put", [202, "Ben", 20, 1]],
  ["get", [101, 2]],
  ["put", [303, "Chen", 30, 3]],
  ["get", [202, 4]],
  ["cleanup", [10]],
  ["size", [10]],
  ["get", [303, 10]]
]

Output, with one result per call:
[null, null, null, "Ada", null, null, 1, 1, "Chen"]

Explanation: Reading member 101 makes member 202 least recently used, so inserting member 303 evicts member 202. Member 101 expires exactly at 0 + 10 = 10; cleanup removes it. Member 303 expires at 3 + 30 = 33, so it remains available.
Example 2:
Input sequence:
[
  ["MemberProfileCache", [2]],
  ["put", [7, "old", 5, 0]],
  ["put", [7, "new", 10, 2]],
  ["put", [8, "other", 20, 3]],
  ["cleanup", [5]],
  ["get", [7, 5]],
  ["cleanup", [12]],
  ["get", [7, 12]],
  ["size", [12]]
]

Output:
[null, null, null, null, 0, "new", 1, null, 1]

Explanation: The original version of member 7 expired at 5, but it was replaced. Its replacement expires at 2 + 10 = 12, so cleanup at 5 removes no current entries. At 12, the replacement expires; member 8 remains live until 3 + 20 = 23.
Constraints
  • 1 <= capacity <= 100000; at most 200000 method calls.

  • 1 <= member_id <= 10^12; summaries contain 0–4096 characters.

  • 0 <= now_ms <= 10^15; 1 <= ttl_ms <= 10^12; calls use nondecreasing times, including repeated timestamps.

  • Inputs satisfy these bounds. Calls are single-threaded; no background worker or real-time clock is required.

  • Capacity limits entries, not bytes. O(capacity) storage refers to metadata and stored entries, excluding the variable length of their string payloads.
Want to practise this one?
Create a free account to open the full question and practise LinkedIn questions with AI.
Sign up free
system design Senior api design #2

2. [OA] Twitter Feed — Design a system to display recent activities for LinkedIn users

LinkedIn needs a feature similar to Twitter feeds, where users can see recent activities of their connections. This involves multiple classes coordinating data retrieval and display.
Problem statement: Design a class TwitterFeed that handles user activity feeds and allows users to follow/unfollow other users.
  • Input: Methods to postTweet(userId: int, tweet: str), getNewsFeed(userId: int), follow(followerId: int, followeeId: int), and unfollow(followerId: int, followeeId: int).

  • Output: List[str] for getNewsFeed, containing up to 10 most recent tweets from the user and their followed users.

  • Constraints:

  • UserIds are in the range of 1 to 10^4

  • Tweet content can be up to 140 characters.
system design Senior caching #3

3. [OA] LRU Cache — Design a caching mechanism to store recently accessed user profiles

To enhance performance, LinkedIn requires a caching system that follows the LRU (Least Recently Used) principle for user profile data retrieval.
Problem statement: Design and implement a class LRUCache that supports the following operations:
  • get(key: int) -> int: Returns the value of the key if the key exists, otherwise return -1.

  • put(key: int, value: int): Update the value of the key if the key exists, or add the key-value pair if the key does not exist. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.

  • Input: capacity - maximum number of items the cache can hold.

  • Output: int for get, no output for put.


Example 1:
Input: ["LRUCache", "put", "put", "get", "put", "get", "get", "put", "get"], [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4], [1], [3]]
Output: [null, null, null, 1, null, 2, -1, null, 3]
Explanation: The cache operates under the mentioned rules and examples.
Constraints:
  • 1 <= capacity <= 3000

  • 0 <= key, value <= 10^4

Related LinkedIn Software Engineer interview prep

Start practicing LinkedIn questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free