LinkedIn software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for LinkedIn.
null.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.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.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.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.[ ["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]] ]
[null, null, null, "Ada", null, null, 1, 1, "Chen"]
0 + 10 = 10; cleanup removes it. Member 303 expires at 3 + 30 = 33, so it remains available.Example 2:[ ["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]] ]
[null, null, null, null, 0, "new", 1, null, 1]
2 + 10 = 12, so cleanup at 5 removes no current entries. At 12, the replacement expires; member 8 remains live until 3 + 20 = 23.Constraints1 <= 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.TwitterFeed that handles user activity feeds and allows users to follow/unfollow other users.postTweet(userId: int, tweet: str), getNewsFeed(userId: int), follow(followerId: int, followeeId: int), and unfollow(followerId: int, followeeId: int).List[str] for getNewsFeed, containing up to 10 most recent tweets from the user and their followed users.UserIds are in the range of 1 to 10^4Tweet content can be up to 140 characters.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.capacity - maximum number of items the cache can hold.int for get, no output for put.1 <= capacity <= 30000 <= key, value <= 10^4Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free