Linkedin interview questions

96 questions from 16 interviews · updated from reports 2014-2024

Practise Linkedin-style

About

LinkedIn is a professional networking platform owned by Microsoft, used for job search, recruiting, learning, and sharing work-related content. In India, it is known for hiring software engineers and software engineering interns for product, backend, data, and platform teams.

The roles that come up most are Software Engineer, Software Engineer Intern and Software Engineering Intern. This covers 16 candidate interviews reported from 2014 to 2024. The largest group sat it at internship level (7 of 15 that recorded a level). Among the 11 that recorded either route, arrivals split between campus drives (5, 45%) and off-campus applications (6, 55%). Most questions fall under DSA and CS fundamentals.

Category
Difficulty
Round

Interview questions

Q. Detect a cycle in an undirected graph.

asked 1xmediumGraphsTechnical2019

Ans. Use DFS and track the parent of each visited node; if you reach an already visited neighbour that is not the parent, a cycle exists. Store the graph as an adjacency list and maintain a visited set or array. Run DFS from every unvisited node to cover disconnected graphs. Time is O(V + E), space is O(V).

Q. Serialize and deserialize a binary tree.

asked 1xmediumTreesTechnical2014

Ans. Serialize the tree using preorder traversal and record null children with a sentinel, then deserialize by reading the values back in the same order. Use a list or stream of tokens and a recursive index or queue. Each node and null marker is processed once, so time is O(n) and space is O(n).

Q. Find all factor combinations for a given number.

asked 1xmediumRecursionTechnical2019

Ans. Use backtracking to build factor lists whose product equals the number, trying factors from a minimum start value to avoid duplicate orders. Store the current combination in a list and add a copy when a valid factor pair is found. Search only up to sqrt(remaining). Time is output-sensitive, mainly proportional to generated combinations.

Q. Explain modern web architecture as it stands today.

asked 1xmediumWeb architectureManagerial2020

Ans. Modern web architecture is a layered, distributed model where browsers or mobile clients talk to backend services through APIs, usually behind CDNs, load balancers and gateways. The key detail is separation of concerns: frontend, services, data stores, caching, messaging, observability and deployment pipelines are designed to scale, fail and change independently.

Q. Given a string, find the number of unique substrings

asked 1xmediumStringsOnline test2017

Ans. Build a suffix automaton and count unique substrings as the sum, over every state except the initial state, of maxLength[state] minus maxLength[suffixLink[state]]. Each state represents a group of substrings with shared end positions. This gives the number of distinct substrings in O(n) time and O(n) space.

Q. Design a system architecture for an application at scale

asked 1xmediumArchitectureSystem design2021

Ans. Use a layered architecture with DNS, CDN, load balancers, stateless application services, cache, database, message queues, and observability. The most important detail is separating read, write, and asynchronous paths so each can scale independently. Use autoscaling services, replicated databases, Redis for hot data, queues for background work, and metrics-driven capacity planning.

Q. Write SQL queries to solve medium-difficulty DBMS problems

asked 1xmediumSQLOnline test2021

Ans. Use joins, grouping, filtering, subqueries, and window functions to express the required result set clearly. Start from the tables and relationships, join only needed rows, aggregate with group by, filter groups with having, and rank or compare rows with window functions. Indexes on join, filter, and sort columns matter most for performance.

Q. Find the longest palindromic subsequence in a given string.

asked 1xmediumDynamic programmingTechnical2014

Ans. Use dynamic programming where dp[i][j] stores the length of the longest palindromic subsequence inside s[i..j]. If s[i] equals s[j], set it to 2 plus dp[i+1][j-1], otherwise take the maximum of excluding either end. Fill by increasing substring length. Time is O(n²), space is O(n²).

Q. Check if there exists a triplet in an array with a given target sum.

asked 1xmediumArraysTechnical2020

Ans. Sort the array, then fix each element one by one and use two pointers on the remaining part to find whether the other two numbers sum to target minus the fixed value. Move the left or right pointer based on the current sum. This takes O(n²) time and O(1) extra space.

Q. Given a string S, find the longest subsequence of S that is a palindrome.

asked 1xmediumDynamic programmingOnline test2018

Ans. Use dynamic programming on intervals to find the longest palindromic subsequence. Let dp[i][j] be the answer length for S[i..j]. If S[i] equals S[j], dp[i][j] = 2 + dp[i+1][j-1]; otherwise take max of excluding either end. Fill by increasing length. Time is O(n²), space is O(n²).

Q. Design a scalable file server system and handle scalability at each component

asked 1xmediumScalabilitySystem design2017

Ans. Use stateless file service nodes behind load balancers, storing file bytes in distributed object storage and metadata in a replicated, sharded database. Scale uploads with chunking and resumable writes, downloads with CDN and edge caching, and background queues for virus scans, thumbnails and replication. Use consistent IDs, access control, checksums, versioning and monitoring.

Q. Explain the rolling hash technique and its applications in string algorithms.

asked 1xmediumStringsTechnical2014

Ans. Rolling hash computes a hash for each fixed length substring by updating the previous hash in constant time as the window moves. Usually it uses a polynomial hash with modular arithmetic. It powers Rabin-Karp pattern matching, fast substring comparison, duplicate substring search, and plagiarism detection. The key issue is handling collisions, often by verification or double hashing.

Q. Extract all leaf nodes of a binary tree and store them in a doubly linked list.

asked 1xmediumTreesTechnical2014

Ans. Do a depth first traversal and whenever a leaf is found, append it to the tail of a doubly linked list using its left and right pointers as previous and next. Use postorder if the leaves must be removed from the tree, returning null to the parent. Time is O(n), extra stack space is O(h).

Q. Find the minimum sum of the product of two arrays by rearranging their elements.

asked 1xmediumGreedyTechnical2020

Ans. Sort one array in ascending order and the other in descending order, then multiply corresponding elements and add the products. This gives the minimum possible sum by pairing small values with large values. The main data structure is the arrays themselves after sorting. Time complexity is O(n log n), dominated by sorting.

Q. Evaluate the value of an arithmetic expression written in Reverse Polish Notation.

asked 1xmediumStacksTechnical2020

Ans. Use a stack and scan the tokens from left to right. Push numbers onto the stack; when you see an operator, pop the right operand first, then the left operand, apply the operator, and push the result back. The final stack value is the answer. Time complexity is O(n), space complexity is O(n).

Q. Explain XSS attacks and how to prevent them. Do the same for SQL Injection attacks.

asked 1xmediumNetworkingManagerial2015

Ans. XSS injects malicious script into pages viewed by users, while SQL injection injects SQL into database queries. Prevent XSS by escaping output, sanitising trusted HTML, using CSP, and avoiding unsafe DOM APIs. Prevent SQL injection by using parameterised queries or prepared statements, not string concatenation, plus least privilege and careful input validation.

Q. Given a binary tree, check whether it is a Binary Search Tree with O(1) extra space.

asked 1xmediumTreesTechnical2014

Ans. Use Morris inorder traversal and verify that values appear in strictly increasing order. Keep only the previous visited value or node, so extra space is O(1). Temporarily create and later remove threads from each node’s inorder predecessor to avoid recursion or a stack. The traversal takes O(n) time and restores the tree.

Q. Design an algorithm to calculate the stock span for each day given daily stock prices.

asked 1xmediumStackTechnical2023

Ans. Use a monotonic decreasing stack to keep indices of days with prices greater than the current price. For each price, pop while the stack top price is less than or equal to it, then the span is the distance to the remaining top index, or i + 1 if empty. This runs in O(n) time.

Q. Given a matrix of 0s and 1s, find the number of connected components consisting of 1s.

asked 1xmediumGraphsTechnical2014

Ans. Scan the matrix and start a DFS or BFS whenever you find an unvisited 1, counting one new component each time. Mark all reachable 1s as visited using four-directional neighbours, unless diagonal connectivity is specified. The time complexity is O(rows × columns), with O(rows × columns) worst-case extra space.

Q. Explain the approach and write pseudocode for a medium-level DSA problem.

asked 1xmediumMixedTechnical2024

Ans. Start by identifying the core pattern, such as two pointers, sliding window, BFS, DFS, heap, or dynamic programming. State the invariant, choose the supporting data structure, then describe each step in order. Finish with time and space complexity, for example linear time and linear space for a hash map based solution.

Q. Networking-focused questions including practical networking aspects relevant to system design

asked 1xmediumNetworkingTechnical2017

Ans. Please provide the specific networking question you want answered. Networking for system design can cover latency, DNS, TCP versus UDP, HTTP, load balancing, TLS, retries, timeouts, proxies, CDNs, NAT, ports, and failure handling, and each needs a different concise interview-style answer.

Q. Which database should be used in which scenarios, especially comparing SQL and NoSQL databases?

asked 1xmediumDBMSSystem design2015

Ans. Use SQL when data is structured, relationships matter, and you need strong consistency, transactions, and complex queries. Use NoSQL when the data is flexible, high-volume, distributed, or needs very fast reads and writes at scale. The key trade-off is usually strict relational integrity versus horizontal scalability and schema flexibility.

Q. Design an efficient approach to check for isomorphic words in a file using a map-based solution.

asked 1xmediumStringsSystem design2014

Ans. Create a canonical pattern for each word using a map from character to the order in which it first appears, then compare or group words by that pattern. For example, “paper” and “title” both map to the same pattern. Reset the map per word. The total time is O(total characters).

Q. Given an unsorted array of positive integers, find all possible triplets that can form a triangle.

asked 1xmediumArraysTechnical2015

Ans. Sort the array, then use the triangle rule: for sorted values a <= b <= c, a triplet is valid if a + b > c. Fix each element as the largest side and use two pointers on the left. This finds all valid triplets in O(n² + T) time, where T is the number output.

Q. Optimal Strategy for a Game problem where two players pick values optimally to maximize their score.

asked 1xmediumDynamic programmingTechnical2014

Ans. Use dynamic programming on intervals, where dp[i][j] stores the maximum score the current player can secure from values i to j. The key recurrence is choosing left or right, then assuming the opponent also plays optimally. Fill smaller intervals first. This uses a 2D table and takes O(n²) time and O(n²) space.

Q. Explain the Fisher-Yates shuffle algorithm and why it produces equal probability for all permutations.

asked 1xmediumProbabilityTechnical2014

Ans. Fisher-Yates shuffles an array by scanning from the last position to the first, swapping each position with a randomly chosen position from the unshuffled part, including itself. At step i there are i plus 1 equally likely choices, so each element is fixed once with equal chance, giving every permutation probability 1 divided by n factorial.

Q. Given the preorder traversal of a binary tree, check whether it represents a valid Binary Search Tree (BST).

asked 1xmediumTreesOnline test2018

Ans. Use a stack and a lower bound to check it in one pass. Traverse the preorder values; if any value is less than the current lower bound, it is invalid. While the value is greater than the stack top, pop and update the lower bound. Push the value. This takes O(n) time and O(n) space.

Q. Given a number N, print all combinations in which the number can be represented as a sum of positive integers

asked 1xmediumBacktrackingTechnical2014

Ans. Use backtracking to build each sum, choosing the next positive integer from the previous chosen value up to the remaining total. This keeps combinations in nondecreasing order, so duplicates like 1+2 and 2+1 are avoided. Store the current combination in a list. Time is proportional to the number of partitions printed.

Q. Discuss high-level system design considerations for breaking down a single monolithic application into components.

asked 1xmediumArchitecture2020

Ans. Break the monolith along clear business capabilities, not technical layers, so each component owns a coherent domain, data, and interface. Start by identifying bounded contexts, dependencies, data ownership, and change frequency. The most important detail is to migrate incrementally, using stable APIs and observability to reduce risk while avoiding distributed monoliths.

Q. Given a mapping between numbers and alphabets and a numeric string, find the number of ways to decode the sequence.

asked 1xmediumDynamic programmingTechnical2014

Ans. Use dynamic programming, where dp[i] is the number of ways to decode the prefix ending at position i. Add dp[i - 1] if the current digit is 1 to 9, and add dp[i - 2] if the previous two digits form 10 to 26. Handle 0 only as part of 10 or 20. Time is O(n).

Q. Perform level order traversal of a binary tree and print a special character (e.g., '$') after completing each level

asked 1xmediumTreesTechnical2014

Ans. Use breadth first search with a queue, processing nodes level by level and printing '$' after each level finishes. The cleanest method is to store the current queue size, process exactly that many nodes, enqueue their children, then print '$'. Time complexity is O(n), and space complexity is O(w), where w is tree width.

Q. Given a string and a pattern, find the smallest window in the string that contains all the characters of the pattern.

asked 1xmediumStringsTechnical2019

Ans. Use a sliding window with two frequency maps: one for the pattern and one for the current window. Expand the right pointer until all required characters are covered, then move the left pointer to shrink while still valid. Track the shortest valid window. This runs in O(n) time with O(k) space.

Q. Given a string, print all unique strings of length k formed from its characters such that characters are in increasing order

asked 1xmediumBacktrackingOnline test2017

Ans. Sort the characters, remove duplicates, then use backtracking to generate combinations of length k in increasing index order. Keep a current character buffer and, at each step, choose the next character only from positions after the previous one. This prints each valid string once. Time complexity is O(C(n, k) · k).

Q. Find the minimum number of moves required for a knight to reach a given ending position from a given starting position on a chessboard.

asked 1xmediumGraphsOnline test2018

Ans. Use breadth first search from the starting square, and the first time you reach the target square is the minimum number of knight moves. Treat each board square as a graph node with up to eight knight edges. Store positions and distance in a queue, mark visited squares, and run in O(rows × columns) time and space.

Q. Given start and end times of n tasks, find the minimum number of machines required so that no two overlapping tasks run on the same machine.

asked 1xmediumPriority queueOnline test2023

Ans. Sort all start times and end times separately, then sweep through them to find the maximum number of simultaneous tasks. If the next task starts before the earliest current task ends, need one more machine; otherwise free one. The maximum active count is the answer. Time complexity is O(n log n).

Q. Given a string containing characters and numbers, parse all numeric values (including negatives and decimals), sum them, and return the result.

asked 1xmediumStringsTechnical2015

Ans. Scan the string once, extract each valid number token, convert it to a numeric type, and add it to a running sum. Use a small buffer or indices to capture optional minus signs, digits, and one decimal point. This uses constant extra space apart from the token and runs in O(n) time.

Q. Find the total number of visible nodes in a binary tree, where a node is visible if it has the highest value on the path from the root to that node.

asked 1xmediumTreesTechnical2018

Ans. Use depth first search from the root, carrying the maximum value seen so far on the current path, and count a node if its value is greater than or equal to that maximum. Then update the maximum before visiting its children. This visits each node once, uses recursion or a stack, and runs in O(n) time.

Q. Design the backend database for an e-commerce product page to support displaying product details, average rating, and number of customers for each rating.

asked 1xmediumDatabase designManagerial2014

Ans. Use a products table for product details, a reviews table for individual customer ratings, and a product_rating_summary table storing total reviews, rating sum, average rating, and counts for 1 to 5 stars. Update the summary when a review is created, changed, or deleted, ideally transactionally or via reliable event processing.

Q. Given a string of comma-separated integers, find the longest subsequence consisting of consecutive integers (in any order) and print them in increasing order

asked 1xmediumArraysOnline test2017

Ans. Parse the integers into a hash set, then find the longest consecutive run by only starting from numbers whose predecessor is absent. For each start, count upwards while values exist, track the best start and length, then print that range in increasing order. This is O(n) time and O(n) space.

Q. Given a matrix where data[i][j] denotes the j-th employee's attendance on the i-th day, find the maximum number of consecutive days when all employees were present.

asked 1xmediumArraysOnline test2018

Ans. Scan the matrix row by row and count a streak only for days where every employee is present. For each day, check all columns; if all values show present, increment current streak, otherwise reset it to zero. Track the maximum streak seen. Time complexity is O(days × employees), with O(1) extra space.

Q. Given n ticket windows with ai tickets each, where ticket price equals remaining tickets in that window at sale time, find the maximum revenue after selling m tickets.

asked 1xmediumGreedyOnline test2014

Ans. Use a max heap of ticket counts and always sell from the window with the most remaining tickets. Add that value to revenue, decrement it, and push it back if still positive. This greedy choice is optimal because the current highest price should never be delayed. Time complexity is O(m log n).

Q. Find the repeating and the missing number in an array of size n containing numbers from 1 to n. Discuss multiple solutions along with their time and space complexities.

asked 1xmediumArraysManagerial2015

Ans. Find the repeating and missing number by comparing the array with the expected numbers from 1 to n. A hash set or frequency array gives O(n) time and O(n) space. Sorting gives O(n log n) time and O(1) extra space. Sum and sum of squares, or XOR, gives O(n) time and O(1) space.

Q. Design a system where a PPT is viewed live by N users in their browsers, and pressing next/previous by the presenter updates the slide for all connected users in real time.

asked 1xmediumReal time systemsSystem design2014

Ans. Use a WebSocket based session service: users join a presentation room, and the presenter’s next or previous action updates the current slide number in the backend and broadcasts it to all sockets in that room. Store slides in object storage/CDN, keep session state in Redis or a database, and use pub/sub for scaling.

Q. Given the root of a binary tree and two values val1 and val2, find the length of the path between the two nodes. Handle corner cases where both values lie on the same path.

asked 1xmediumTreesTechnical2014

Ans. Find the lowest common ancestor of the two nodes, then return distance from the ancestor to val1 plus distance from the ancestor to val2. If one node lies on the path to the other, the ancestor is that node, so one distance is zero. Use DFS, with O(n) time and O(h) stack space.

Q. Given an array receiver where receiver[i] indicates the next friend a ball is passed to each second (1-indexed), starting from friend 1, determine which friend has the ball after k seconds.

asked 1xmediumGraphsOnline test2023

Ans. Simulate passes from friend 1, but detect the first repeated friend to avoid doing all k steps. Store each visited friend in order and its first time. When a repeat appears, the path has entered a cycle, so reduce the remaining seconds modulo the cycle length. This is O(n) time and O(n) space.

Q. Given an array of integers, repeatedly remove any two elements, add their sum back to the array, and incur a cost equal to that sum. Find the minimum total cost required to reduce the array to a single element.

asked 1xmediumGreedyOnline test2017

Ans. Use a min-heap and always merge the two smallest elements first. Each time, extract the two minimum values, add their sum to the total cost, and insert the sum back into the heap. This greedy choice minimises repeated contribution of large values. The time complexity is O(n log n), with O(n) space.

Q. Given an array counts where counts[i] represents the size of the friend group user i belongs to, determine whether the implied grouping of users into friend groups is valid based on minimal user IDs for each group size.

asked 1xmediumGraphsOnline test2017

Ans. A grouping is valid if, for every size s, the number of users whose count is s is divisible by s. Store user IDs in a hash map keyed by count, in ascending order, then split each list into blocks of size s. Each block’s first ID is its minimal user ID. Time is O(n).

Q. Given a 2D matrix of size MxN filled with 0s and 1s, starting from (0,0) you can move only right or down. A cell with 1 is passable and 0 is blocked. Count the number of paths from (0,0) to (M-1,N-1). Return the result modulo 1e9+7.

asked 1xmediumDynamic programmingOnline test2015

Ans. Use dynamic programming where dp[j] stores the number of ways to reach the current row’s cell in column j. If a cell is blocked, set dp[j] to 0; otherwise add paths from the top and left modulo 1e9+7. Initialise only if start is passable. Time is O(MN), space is O(N).

Q. There are n ticket windows at a railway station, where the i-th window has ai tickets available. The price of a ticket is equal to the number of tickets remaining at that window at the time of sale. If m tickets are sold in total, what is the maximum revenue that can be earned?

asked 1xmediumGreedyOnline test2014

Ans. Use a greedy approach: always sell the next ticket from the window with the most tickets remaining. Store all ai values in a max heap, repeatedly pop the largest value, add it to revenue, decrement it, and push it back if still positive. This gives maximum revenue in O(m log n) time.

Q. There are n ticket windows in a railway station. The i-th window has ai tickets available. The price of a ticket is equal to the number of tickets remaining in that window at the time of sale. If m tickets are sold in total, what is the maximum amount of money that can be earned?

asked 1xmediumGreedyOnline test2015

Ans. Use a max heap of ticket counts and always sell from the window with the most remaining tickets. For each of the m sales, pop the maximum count, add it to revenue, decrement it, and push it back if still positive. Time complexity is O((n + m) log n), space O(n).

Q. Design a Google Calendar–like system.

asked 1xhardScalable systemsSystem design2019

Ans. Design it as a multi-tenant calendar service with event, attendee, availability, notification and sharing APIs backed by a strongly consistent store for event ownership and invitations. The most important detail is conflict-free scheduling: store events with time ranges and time zones, index by user and time, and use transactions for create, update and RSVP changes.

Q. Design a complete system for a traffic enforcement camera.

asked 1xhardScalable systemsSystem design2015

Ans. A traffic enforcement camera system needs roadside capture, local offence detection, secure evidence handling and central review. The camera timestamps and geotags images, uses radar or loop sensors plus ANPR, signs evidence cryptographically, and uploads it over a secure link. The key detail is evidential integrity: calibration, audit logs and tamper-proof storage must be defensible.

Q. How would you handle system design challenges during a company merger or large-scale migration?

asked 1xhardMigrationManagerial2020

Ans. I would handle it with a phased migration plan that protects service continuity and data integrity. First, map systems, ownership, dependencies, SLAs and data flows, then define the target architecture and integration contracts. The key detail is reducing risk through incremental cutovers, validation, monitoring, rollback paths and clear ownership for each service.

Q. Given a string, find the number of distinct substrings with optimized time and space complexity.

asked 1xhardStringsOnline test2014

Ans. Use a suffix automaton and count distinct non-empty substrings as the sum over all states of length[state] minus length[suffix_link[state]]. Build the automaton in linear time while scanning the string. Each state represents an equivalence class of substrings, so this formula counts each distinct substring exactly once. Time is O(n), space is O(n).

Q. Explain the approach and write pseudocode for a hard-level DSA problem related to trees or graphs.

asked 1xhardGraphsTechnical2023

Ans. Use Tarjan’s algorithm to find bridges in an undirected graph with one DFS. Store discovery time and low-link value for each node; after visiting a child, update the parent’s low value. If low[child] is greater than disc[parent], that edge is a bridge. Use adjacency lists. Time is O(V + E).

Q. Given a string, find the number of distinct palindromic substrings with optimized time complexity.

asked 1xhardStringsOnline test2014

Ans. Use a palindromic tree, also called an Eertree, to count distinct palindromic substrings in O(n) time. Insert characters one by one, maintaining suffix links to the longest palindromic suffix. Each new node represents one new distinct palindrome, so the answer is the number of nodes excluding the two roots.

Q. How do you choose between scalability, performance, and quality when making engineering decisions?

asked 1xhardTrade offs2020

Ans. I choose based on the product goal, current bottleneck, and cost of being wrong. Quality is the baseline for correctness, security, and maintainability. Performance matters when users feel latency or cost rises. Scalability matters when growth is likely or failure impact is high. I prefer measured trade-offs over speculative optimisation.

Q. How do you handle conflict resolution with your peers?

asked 1xunknownConflict resolution2020

Ans. Choose a real peer conflict where the stakes mattered but emotions stayed manageable. Emphasise listening first, separating facts from assumptions, agreeing shared goals, and finding a practical compromise or escalation path. Interviewers listen for maturity, accountability, respect, clear communication, and evidence that the relationship and work both improved.

Q. Is there a cost to code reviews, and how do you balance it?

asked 1xunknownDecision making2020

Ans. A strong answer says yes, code reviews cost time, attention, and context switching, but reduce defects, improve maintainability, and share knowledge. Pick a real example where review depth matched risk. Emphasise small changes, clear standards, timely feedback, automation for style, and trust. Interviewers listen for pragmatism, not review theatre.

Q. How do you manage people, including hiring and firing decisions?

asked 1xunknownLeadershipManagerial2020

Ans. Pick a real example showing fair, structured people management across hiring, development, performance issues, and exits. Emphasise clear expectations, evidence-based decisions, coaching, documentation, legal or HR process, and respect for the individual. Interviewers listen for judgement, consistency, accountability, lack of ego, and willingness to make hard decisions humanely.

Showing 60 of 96 questions. Ranked by how often the same question came back across interviews.

Practise a Linkedin-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does Linkedin ask?

Candidate interviews most often cover DSA (57%) and CS fundamentals (26%).

How many rounds does Linkedin interview have?

Candidate interviews show an average of 3.9 rounds per experience, with a typical sequence of Online test. Individual interview paths can vary.

Is the Linkedin interview hard?

Among questions with a recorded difficulty, the mix is easy 32%, medium 56%, hard 12%.