Linkedin Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
Solve min window & animal conflicts
Question LeetCode 76. Minimum Window Substring: Given strings s and t, return the smallest substring of s that contains every character of t (includin...
Reverse a linked list
Question LeetCode 206. Reverse Linked List — Given the head of a singly linked list, reverse the list and return the reversed list. https://leetcode.c...
Find lowest common ancestor
Question LeetCode 236. Lowest Common Ancestor of a Binary Tree — Given a binary tree, find the lowest common ancestor (LCA) of two given nodes. Follow...
Count islands and distinct shapes
Question LeetCode 200. Number of Islands LeetCode 694. Number of Distinct Islands https://leetcode.com/problems/number-of-islands/description/ https:/...
Compute graph distance and impacted services
Part A — Graph shortest distance (BFS) You are given an interface representing a node in an unweighted graph: `java interface Candidate { String id(...
Implement an LRU cache with follow-ups
Coding: Implement an LRU Cache and discuss concurrency Design and implement an in-memory Least Recently Used (LRU) cache data structure. The cache sho...
Find the k-th largest element in an array
Given an integer array nums and an integer k, return the k-th largest element in the array. Notes: - The k-th largest element is the element that woul...
Merge two N-ary trees by key rules
You are given two N-ary trees A and B. Each node has: - key (string): unique among siblings (i.e., within a node’s children list, no two children shar...
Count connected land components in a grid
You are given a 2D grid of characters where: - '1' represents land - '0' represents water A group of land cells forms an island if they are connected ...
Group words that map to same phone digits
Problem On a classic phone keypad (T9), letters map to digits: - 2: ABC, 3: DEF, 4: GHI, 5: JKL, - 6: MNO, 7: PQRS, 8: TUV, 9: WXYZ Given a list of lo...
Validate parentheses with one or three bracket types
Problem Given a string s consisting only of bracket characters, determine whether it is valid. A string is valid if: - Every opening bracket has a cor...
Implement fast sampling for weighted k-sided die
You must sample from a categorical distribution over k outcomes with probabilities p1..pk (sum to 1) without using built-in categorical samplers. You ...
Solve substring and top‑K pair problems
Problem A: Smallest window containing all characters Given two strings s and t, find the shortest substring of s that contains all characters of t wit...
Solve six algorithmic problems
Answer the following independent algorithmic prompts. For each, explain your approach, justify data structures, analyze time/space complexity, and pro...
Compare heap and stack memory
Compare heap and stack memory. Explain how each is allocated and freed, typical lifetimes of data stored there, access patterns and performance charac...
Determine sanitized palindrome in string
Write a function that determines whether a string is a palindrome after removing non-alphanumeric characters and ignoring case (e.g., punctuation, whi...
Detect intersection of two linked lists
Given two singly linked lists that may converge to share a common tail, determine whether they intersect and return the first node at which they join....
Differentiate Java final, finalize, finally
Differentiate Java's final, finalize, and finally. Define what final means for variables, methods, and classes and give examples; explain what finaliz...
Find k closest values in a BST
Given a binary search tree with n nodes and a real target t, return k node values whose distances to t are smallest. Implement an algorithm with O(log...
Minimize adjacent-color assignment cost
You are given H linear items (e.g., houses) and an H×C cost matrix where cost[i][c] is the cost of assigning color c to item i. Adjacent items cannot ...