Meesho Previous Year Coding Questions

Meesho is India's largest social commerce platform, known for its zero-commission model for resellers and small businesses. It hires SDE-1, SDE-2, Backend Engineers, and Data Engineers through campus (Open Campus) drives, off-campus applications, and lateral hiring, primarily for its Bangalore engineering teams. The process leans heavily on Data Structures & Algorithms across two to three live coding rounds, with a dedicated Machine Coding/LLD round for backend roles and a System Design round for SDE-2 and above. Interviewers consistently report that clean, working code and the ability to explain your reasoning matter as much as reaching the optimal solution.


Hiring Process

Step 1: Resume Screening Meesho shortlists candidates based on academic background, relevant projects, and prior internship or work experience. Open Campus drives are open to final-year students and recent graduates across branches.

Step 2: Online Assessment Duration: around 165 minutes on HackerRank or a similar proctored platform. Contains 3 coding questions (typically 2 Medium and 1 Hard) plus 20 MCQs split evenly across Operating Systems, Computer Networks, C/C++ output-based questions, and Java fundamentals.

Step 3: DSA Live Coding Round 1 45–60 minutes over HackerRank CodePair or a similar shared editor. Usually 2 problems ranging from Medium to Hard, with an emphasis on arrays, strings, graphs, and dynamic programming. Candidates are expected to talk through their approach before coding.

Step 4: DSA Live Coding Round 2 A second, often harder DSA round, sometimes combined with a pen-and-paper problem you explain to the interviewer after a short prep window. For SDE-2 candidates, this round may combine two medium-to-hard problems in one session.

Step 5: Machine Coding / LLD Round 60–90 minutes. Candidates build a working mini-system from a product requirement, most commonly an Inventory Management Service, a social feed (follow/post/paginated top-K feed), or a doctor/slot booking system. Graded on OOP design, SOLID principles, and whether the code actually runs.

Step 6: System Design / HLD Round (SDE-2+) Covers Meesho-scale systems: product catalog and search, order management, and reseller commission/payout flows. Expect questions on caching, database sharding, and handling traffic spikes during sale events.

Step 7: Hiring Manager / HR Round A conversation about your background, past projects, and interest in Meesho's mission of enabling small businesses and resellers. Standard behavioural and culture-fit questions.

Tips: The OA's MCQ section (OS, CN, C/C++ output, Java) is often underestimated, brush up on core CS fundamentals alongside DSA practice. The Machine Coding round carries real weight for backend roles, practice a clean Inventory Management System end to end (add product, add stock, block stock during checkout, release on payment failure) before your interview.


Preparation Resources

Part 1 — OA Questions

1. Maximum Sum of M Non-Overlapping Subarrays of Size K Medium

OA Dynamic Programming · Sliding Window LeetCode:{' '} #689

Meesho's OA generalises LeetCode 689 from exactly 3 fixed-size subarrays to M non-overlapping subarrays of size K. Given an integer array and integers K and M, find the maximum possible sum of M non-overlapping subarrays each of length K.

Input: nums = [1,2,1,2,6,7,5,1], k = 2, m = 2
Output: 20
Explanation: Take subarrays [2,6] and [7,5] (or similar), sum = 20.

Approach: Compute prefix sums of every window of size K first. Then run a DP where dp[i][j] = best sum using the first i windows while picking j of them, transitioning between "skip this window" and "take this window + dp[i-k][j-1]". Complexity: Time O(n * m) · Space O(n * m) Follow-up: What if the subarrays are allowed to be of variable length between K1 and K2?


2. Intersection of Two Arrays II Easy

OA Arrays · Hashing LeetCode:{' '} #350

Given two integer arrays, return an array of their intersection in ascending order. Each element in the result should appear as many times as it shows in both arrays.

Input: nums1 = [1,2,2,1], nums2 = [2,2]
Output: [2,2]

Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Output: [4,9]

Approach: Build a frequency map for the smaller array. Iterate the larger array, and whenever a value has a remaining count greater than 0 in the map, add it to the result and decrement the count. Sort the result at the end. Complexity: Time O(n log n + m) · Space O(min(n, m)) Follow-up: What if both arrays are already sorted? (Two-pointer, no extra space.)


3. Chocolate Distribution Problem Medium

OA Arrays · Sorting · Greedy

A classic GfG-style problem reported in Meesho's OA. Given an array of chocolate packet sizes and a number of students M, distribute one packet to each student such that the difference between the packet with the maximum and minimum chocolates given to a student is minimised.

Input: arr = [7,3,2,4,9,12,56], m = 3
Output: 2
Explanation: The best 3 consecutive-after-sort packets are [2,3,4], difference = 4-2 = 2.

Approach: Sort the array. Slide a window of size M across the sorted array and track the minimum value of (window[last] - window[first]) across all windows. Complexity: Time O(n log n) · Space O(1) Follow-up: What if you had to maximise, instead of minimise, the difference?


4. Longest Increasing Subsequence Medium

OA Dynamic Programming · Binary Search LeetCode:{' '} #300

Given an integer array, return the length of the longest strictly increasing subsequence.

Input: nums = [10,9,2,5,3,7,101,18]
Output: 4
Explanation: The LIS is [2,3,7,101].

Approach: Maintain a "tails" array where tails[i] is the smallest possible tail value of an increasing subsequence of length i+1. For each number, binary search for its position in tails and replace it (or append if it extends the longest subsequence). Complexity: Time O(n log n) · Space O(n) Follow-up: Reconstruct the actual subsequence, not just its length.


5. Graph Colouring (Bipartite Check) Medium

OA Graph · BFS/DFS LeetCode:{' '} #785

Meesho's OA framed this as an M-colouring style question, checkable via a bipartite (2-colour) test: given an undirected graph, determine whether its nodes can be coloured with 2 colours so that no two adjacent nodes share a colour.

Input: graph = [[1,3],[0,2],[1,3],[0,2]]
Output: true
Explanation: Colour nodes 0,2 with colour A and 1,3 with colour B.

Approach: Run BFS/DFS from every uncoloured node, assigning alternating colours to neighbours. If a neighbour already has the same colour as the current node, the graph is not bipartite. Complexity: Time O(V + E) · Space O(V) Follow-up: Extend this to check if the graph can be coloured with exactly K colours (general graph colouring, NP-hard, discuss a backtracking approach).


6. Maximum Sum After Flipping a Subarray of Size K Medium

OA Sliding Window · Bit Manipulation

Given a binary array and a window size K, you may flip every bit inside exactly one contiguous window of size K (0 becomes 1, 1 becomes 0). Return the maximum possible sum of the array after performing at most one such flip.

Input: arr = [0,1,0,0,1,0], k = 3
Output: 4
Explanation: Flipping arr[0..2] gives [1,0,1,0,1,0], sum = 3. Flipping arr[2..4] gives [0,1,1,1,0,0], sum = 3. Flipping arr[1..3] gives [0,0,1,1,1,0], sum = 3. Best achievable here is 4 by flipping a window that contains more zeros than ones — flipping arr[2..4]=[0,0,1] gives [1,1,0], net gain 1, total 4.

Approach: For each window of size K, compute (count of zeros in window - count of ones in window), this is the net gain from flipping that window. Slide the window across the array while maintaining a running count, and track the maximum net gain. Answer = original sum of ones + best net gain (clamped at 0 if all gains are negative). Complexity: Time O(n) · Space O(1) Follow-up: What if you are allowed to perform the flip on up to 2 non-overlapping windows?


Part 2 — Phone Screen Questions

7. Maximum Sum Circular Subarray Medium

Phone Screen Arrays · Kadane's Algorithm LeetCode:{' '} #918

Given a circular integer array, return the maximum possible sum of a non-empty subarray, where the subarray may wrap around from the end of the array back to the beginning.

Input: nums = [1,-2,3,-2]
Output: 3

Input: nums = [5,-3,5]
Output: 10
Explanation: Subarray [5,5] wrapping around, sum = 10.

Approach: Compute the normal Kadane's maximum subarray sum. Separately compute the minimum subarray sum using Kadane's on negated logic. The circular maximum is either the normal max, or (total sum - minimum subarray sum), whichever is larger. Handle the all-negative edge case separately. Complexity: Time O(n) · Space O(1) Follow-up: What if the array is a true circular buffer that keeps growing (streaming), can you maintain the answer incrementally?


8. Count Collisions on a Road Medium

Phone Screen Stack · Simulation LeetCode:{' '} #2211

Reported as a 'balls collision' style question. There are n cars on a road, each moving left, right, or stationary. Two moving cars moving toward each other, or a moving car hitting a stationary one, collide and both become stationary. Return the total number of collisions.

Input: directions = "RLRSLL"
Output: 5

Approach: Use a stack. Push cars moving right. When a car moving left is encountered, pop and count a collision for every right-moving or already-stopped car on top of the stack until the stack top is also moving left or empty, then push the (now stationary) result appropriately. Stationary cars immediately collide with any right-movers before them. Complexity: Time O(n) · Space O(n) Follow-up: Track and return the final resting position of every car, not just the collision count.


9. Minimum Number of Taps to Open to Water a Garden Hard

Phone Screen Greedy · Dynamic Programming LeetCode:{' '} #1326

There is a 1D garden of length n. At each tap position i, water reaches [i - ranges[i], i + ranges[i]]. Return the minimum number of taps to open to water the entire garden, or -1 if impossible.

Input: n = 5, ranges = [3,4,1,1,0,0]
Output: 1
Explanation: Tap at index 0 covers the whole garden [-3,3].

Approach: Convert each tap into an interval, then treat this like the classic "minimum jumps to cover a range" greedy problem: for every starting point, compute the farthest right point reachable, then greedily jump to the interval offering the farthest reach whenever the current one is exhausted. Complexity: Time O(n) · Space O(n) Follow-up: What if taps have an activation cost, and you want to minimise total cost instead of tap count?


10. Max Area of Island Medium

Phone Screen Graph · BFS/DFS LeetCode:{' '} #695

An extension of the classic 'Number of Islands' problem. Given a 2D binary grid, return the area of the largest island (a group of connected 1's, connected 4-directionally).

Input: grid = [[0,0,1,0],[1,1,1,0],[0,0,0,0]]
Output: 4

Approach: Iterate every cell. On an unvisited land cell, run DFS/BFS counting connected land cells while marking them visited, and track the maximum area seen across all islands. Complexity: Time O(rows * cols) · Space O(rows * cols) Follow-up: One extra operation is allowed: flip a single 0 to 1. What is the largest possible island after one flip?


11. Word Break Medium

Phone Screen Dynamic Programming · Trie LeetCode:{' '} #139

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.

Input: s = "leetcode", wordDict = ["leet","code"]
Output: true

Approach: dp[i] = true if s[0..i) can be segmented. dp[0] = true. For each i, check every j < i: if dp[j] is true and s[j..i) is in the dictionary (using a HashSet for O(1) lookup), set dp[i] = true. Complexity: Time O(n^2) · Space O(n) Follow-up: Return all possible segmentations, not just whether one exists (Word Break II).


12. Kth Largest Element in an Array Medium

Phone Screen Heap · Quickselect LeetCode:{' '} &#35;215

Given an integer array and an integer k, return the kth largest element in the array.

Input: nums = [3,2,1,5,6,4], k = 2
Output: 5

Approach: Maintain a min-heap of size k. Push each element, and pop whenever the heap size exceeds k. The heap top at the end is the answer. Quickselect gives average O(n) if the interviewer wants the optimal approach. Complexity: Time O(n log k) with heap, O(n) average with quickselect · Space O(k) Follow-up: What if the array is a live stream and you need the kth largest at any point in time?


13. Course Schedule Medium

Phone Screen Graph · Topological Sort LeetCode:{' '} &#35;207

There are numCourses courses labeled 0 to numCourses - 1. Given a list of prerequisite pairs, determine if it is possible to finish all courses (i.e., the prerequisite graph has no cycle).

Input: numCourses = 2, prerequisites = [[1,0]]
Output: true

Input: numCourses = 2, prerequisites = [[1,0],[0,1]]
Output: false

Approach: Build an adjacency list and in-degree count for each course. Use Kahn's algorithm (BFS): repeatedly remove nodes with in-degree 0, decrementing their neighbours' in-degree. If all nodes are processed, there is no cycle. Complexity: Time O(V + E) · Space O(V + E) Follow-up: Return a valid course order instead of just true/false (Course Schedule II).


Part 3 — Onsite Questions

14. Number of Islands Medium

Onsite Graph · BFS/DFS LeetCode:{' '} &#35;200

Given a 2D binary grid of '1' (land) and '0' (water), return the number of islands, where an island is a group of connected 1's (4-directionally connected).

Input: grid = [["1","1","0","0"],["1","1","0","0"],["0","0","1","0"],["0","0","0","1"]]
Output: 3

Approach: Iterate every cell. On an unvisited land cell, run DFS/BFS to mark the entire connected component as visited, and increment the island count once per new component. Complexity: Time O(rows * cols) · Space O(rows * cols) Follow-up: Solve it using Union-Find instead of DFS/BFS.


15. LRU Cache Medium

Onsite HashMap · Doubly Linked List LeetCode:{' '} &#35;146

Design a data structure that follows the Least Recently Used (LRU) cache eviction policy, supporting get(key) and put(key, value) in O(1) time.

Input: capacity = 2
put(1,1); put(2,2); get(1) → 1; put(3,3) evicts key 2; get(2) → -1

Approach: Combine a HashMap (key → node) with a doubly linked list ordered by recency. get() moves the accessed node to the front. put() adds to the front and evicts the tail node when over capacity. Complexity: Time O(1) per operation · Space O(capacity) Follow-up: Design an LFU (Least Frequently Used) cache instead.


16. Two Sum Easy

Onsite Array · HashMap LeetCode:{' '} &#35;1

Given an array of integers and a target, return indices of the two numbers that add up to target.

Input: nums = [2,7,11,15], target = 9
Output: [0,1]

Approach: Use a HashMap of value → index. For each number, check if (target - number) already exists in the map before inserting the current number. Complexity: Time O(n) · Space O(n) Follow-up: What if the array is sorted? (Two-pointer, O(1) extra space.)


17. Merge Intervals Medium

Onsite Arrays · Sorting LeetCode:{' '} &#35;56

Given an array of intervals, merge all overlapping intervals and return an array of the non-overlapping intervals that cover all the intervals in the input.

Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]

Approach: Sort intervals by start time. Iterate and merge the current interval into the last merged interval if they overlap, otherwise append a new interval. Complexity: Time O(n log n) · Space O(n) Follow-up: Insert a new interval into an already-sorted, non-overlapping list of intervals efficiently.


18. Longest Palindromic Substring Medium

Onsite String · Dynamic Programming LeetCode:{' '} &#35;5

Given a string s, return the longest palindromic substring in s.

Input: s = "babad"
Output: "bab" (or "aba")

Approach: Expand around every possible centre (2n-1 centres for odd and even length palindromes), tracking the longest palindrome found. Manacher's algorithm gives O(n) if required. Complexity: Time O(n^2) (expand-around-centre) · Space O(1) Follow-up: Implement the O(n) Manacher's algorithm solution.


19. Trapping Rain Water Hard

Onsite Two Pointers · Stack LeetCode:{' '} &#35;42

Given n non-negative integers representing an elevation map, compute how much water it can trap after raining.

Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6

Approach: Two pointers from both ends, tracking the max height seen so far on each side. Move the pointer with the smaller max height inward, adding (maxSoFar - height[pointer]) to the total at each step. Complexity: Time O(n) · Space O(1) Follow-up: Solve the 2D version, Trapping Rain Water II, using a priority queue.


20. Binary Tree Level Order Traversal Medium

Onsite Tree · BFS LeetCode:{' '} &#35;102

Given the root of a binary tree, return the level order traversal of its nodes' values (i.e., left to right, level by level).

Input: root = [3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]

Approach: Standard BFS using a queue. Process one full level at a time by tracking the queue size at the start of each level. Complexity: Time O(n) · Space O(n) Follow-up: Return the zig-zag level order traversal instead.


21. Lowest Common Ancestor of a Binary Tree Medium

Onsite Tree · DFS LeetCode:{' '} &#35;236

Given a binary tree and two nodes p and q, find their lowest common ancestor (LCA).

Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
Output: 3

Approach: Recursive DFS: if the current node is p or q, or if p and q are found in different subtrees, the current node is the LCA. Otherwise recurse into whichever subtree contains both. Complexity: Time O(n) · Space O(h) Follow-up: Solve it when nodes have a parent pointer instead of starting from the root.


22. Serialize and Deserialize Binary Tree Hard

Onsite Tree · Design LeetCode:{' '} &#35;297

Design an algorithm to serialize a binary tree to a string, and deserialize that string back into the original tree structure.

Input: root = [1,2,3,null,null,4,5]
Serialized: "1,2,#,#,3,4,#,#,5,#,#"

Approach: Serialize using preorder DFS, using a sentinel (e.g. "#") for null children, comma-separated. Deserialize by reading tokens in the same preorder sequence, recursively rebuilding left and right subtrees. Complexity: Time O(n) · Space O(n) Follow-up: Do the same for an N-ary tree instead of a binary tree.


23. Word Ladder Hard

Onsite Graph · BFS LeetCode:{' '} &#35;127

Given a beginWord, endWord, and a word list, return the length of the shortest transformation sequence from beginWord to endWord, changing one letter at a time, with each intermediate word in the word list.

Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]
Output: 5

Approach: BFS from beginWord. At each step, try changing every character position to every other letter, checking if the resulting word is in the word set. Track visited words to avoid cycles. Complexity: Time O(n * 26 * L) · Space O(n) Follow-up: Return all the shortest transformation sequences, not just the length (Word Ladder II).


24. Top K Frequent Elements Medium

Onsite Heap · HashMap LeetCode:{' '} &#35;347

Given an integer array and an integer k, return the k most frequent elements.

Input: nums = [1,1,1,2,2,3], k = 2
Output: [1,2]

Approach: Count frequencies with a HashMap. Use a min-heap of size k (or bucket sort by frequency) to find the k most frequent elements in better than O(n log n). Complexity: Time O(n log k) (heap) or O(n) (bucket sort) · Space O(n) Follow-up: What if the input is a continuous data stream instead of a fixed array?


25. Product of Array Except Self Medium

Onsite Array · Prefix/Suffix LeetCode:{' '} &#35;238

Given an integer array, return an array where each element is the product of all elements except itself, without using division and in O(n) time.

Input: nums = [1,2,3,4]
Output: [24,12,8,6]

Approach: Compute a prefix-product array and a suffix-product array. The answer at index i is prefix[i-1] * suffix[i+1]. This can be done in-place using the output array for prefix products, then a single backward pass for suffix products. Complexity: Time O(n) · Space O(1) extra (excluding output) Follow-up: Handle zeros in the array without special-casing them separately.


26. Search in Rotated Sorted Array Medium

Onsite Binary Search LeetCode:{' '} &#35;33

Given a rotated sorted array with distinct values and a target, return the index of the target, or -1 if not found, in O(log n) time.

Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4

Approach: Modified binary search. At each step, determine which half (left or right of mid) is properly sorted, then check if the target lies within that sorted half to decide which side to recurse into. Complexity: Time O(log n) · Space O(1) Follow-up: What changes if the array can contain duplicate values?


27. Coin Change Medium

Onsite Dynamic Programming LeetCode:{' '} &#35;322

Given an array of coin denominations and a target amount, return the fewest number of coins needed to make up that amount, or -1 if impossible.

Input: coins = [1,2,5], amount = 11
Output: 3
Explanation: 11 = 5+5+1

Approach: Bottom-up DP where dp[i] = minimum coins to make amount i. dp[0] = 0. For each amount from 1 to target, try every coin and take dp[amount - coin] + 1 if it improves the current best. Complexity: Time O(amount * coins) · Space O(amount) Follow-up: Return the number of distinct combinations that make up the amount instead (Coin Change II).


28. Longest Common Subsequence Medium

Onsite Dynamic Programming · String LeetCode:{' '} &#35;1143

Given two strings, return the length of their longest common subsequence.

Input: text1 = "abcde", text2 = "ace"
Output: 3

Approach: 2D DP table where dp[i][j] = LCS length of text1[0..i) and text2[0..j). If characters match, dp[i][j] = dp[i-1][j-1] + 1, otherwise dp[i][j] = max(dp[i-1][j], dp[i][j-1]). Complexity: Time O(m * n) · Space O(m * n), reducible to O(min(m,n)) Follow-up: Reconstruct the actual longest common subsequence string, not just its length.


29. Subsets Medium

Onsite Backtracking LeetCode:{' '} &#35;78

Given an array of unique integers, return all possible subsets (the power set).

Input: nums = [1,2,3]
Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]

Approach: Backtracking: at each index, branch into "include this element" and "exclude this element", adding the current subset to the result at every recursive call. Complexity: Time O(2^n) · Space O(2^n) Follow-up: Handle duplicate values in the input array without producing duplicate subsets.


30. Permutations Medium

Onsite Backtracking LeetCode:{' '} &#35;46

Given an array of distinct integers, return all possible permutations.

Input: nums = [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]

Approach: Backtracking with a "used" boolean array (or by swapping in place). At each recursive level, try every unused number as the next element, recurse, then backtrack. Complexity: Time O(n * n!) · Space O(n!) Follow-up: Handle duplicate values without producing duplicate permutations (Permutations II).


31. Rotate Image Medium

Onsite Array · Matrix LeetCode:{' '} &#35;48

Given an n x n 2D matrix representing an image, rotate the image by 90 degrees clockwise, in place.

Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [[7,4,1],[8,5,2],[9,6,3]]

Approach: Transpose the matrix (swap matrix[i][j] with matrix[j][i]), then reverse each row. This achieves an in-place 90-degree clockwise rotation. Complexity: Time O(n^2) · Space O(1) Follow-up: Rotate the matrix counter-clockwise instead, and rotate by an arbitrary multiple of 90 degrees.


32. Valid Parentheses Easy

Onsite Stack · String LeetCode:{' '} &#35;20

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid (every open bracket is closed by the same type in the correct order).

Input: s = "()[]{}"
Output: true

Input: s = "(]"
Output: false

Approach: Use a stack. Push opening brackets. On a closing bracket, check the stack top matches the corresponding opening bracket, popping if so, otherwise return false. String is valid if the stack is empty at the end. Complexity: Time O(n) · Space O(n) Follow-up: Return the minimum number of insertions needed to make the string valid, if it is not already.


33. Min Stack Medium

Onsite Stack · Design LeetCode:{' '} &#35;155

Design a stack that supports push, pop, top, and retrieving the minimum element, all in O(1) time.

push(-2); push(0); push(-3); getMin() → -3; pop(); top() → 0; getMin() → -2

Approach: Maintain two stacks: the main stack, and an auxiliary stack that tracks the minimum at each level (push the new min whenever a smaller-or-equal value is pushed onto the main stack). Complexity: Time O(1) per operation · Space O(n) Follow-up: Do it with O(1) extra space per element by storing differences instead of a second stack.


34. Implement Trie (Prefix Tree) Medium

Onsite Trie · Design LeetCode:{' '} &#35;208

Implement a Trie with insert, search, and startsWith methods.

insert("apple"); search("apple") → true; search("app") → false; startsWith("app") → true

Approach: Each Trie node holds a map/array of children (one per possible character) and an isEndOfWord flag. insert() walks/creates nodes character by character. search() and startsWith() walk the same path, differing only in whether the final node must be marked as end-of-word. Complexity: Time O(L) per operation (L = word length) · Space O(total characters inserted) Follow-up: Extend the Trie to support wildcard search where "." matches any character (Design Add and Search Words Data Structure).


35. Design Add and Search Words Data Structure Medium

Onsite Trie · DFS LeetCode:{' '} &#35;211

Design a data structure that supports adding new words and searching for a word, where the search word may contain '.' as a wildcard matching any single letter.

addWord("bad"); addWord("dad"); addWord("mad"); search("pad") → false; search(".ad") → true; search("b..") → true

Approach: Standard Trie for storage. For search, use DFS: on a normal character, follow the matching child; on a wildcard, recursively try every child at that node. Complexity: Time O(26^m) worst case for m wildcards · Space O(total characters inserted) Follow-up: Support word deletion as well.


36. Clone Graph Medium

Onsite Graph · DFS/BFS LeetCode:{' '} &#35;133

Given a reference to a node in a connected undirected graph, return a deep copy (clone) of the graph.

Input: adjList = [[2,4],[1,3],[2,4],[1,3]]
Output: [[2,4],[1,3],[2,4],[1,3]] (deep copy)

Approach: DFS/BFS from the given node, using a HashMap of original node → cloned node to avoid infinite loops and to reuse already-cloned nodes when wiring up neighbours. Complexity: Time O(V + E) · Space O(V) Follow-up: Clone a graph that also has weighted edges.


37. Pacific Atlantic Water Flow Medium

Onsite Graph · DFS/BFS LeetCode:{' '} &#35;417

Given an m x n grid of heights representing a continent, water can flow to a neighbouring cell with height less than or equal to the current cell. Return all cells from which water can flow to both the Pacific (top/left edges) and Atlantic (bottom/right edges) oceans.

Input: heights = [[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]
Output: [[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]

Approach: Run DFS/BFS from all Pacific-adjacent border cells and separately from all Atlantic-adjacent border cells, moving to neighbours with height >= current (reverse flow). Cells reachable from both are the answer. Complexity: Time O(rows * cols) · Space O(rows * cols) Follow-up: What if there were more than 2 oceans, on all 4 sides independently?


38. Kth Smallest Element in a BST Medium

Onsite Tree · Inorder Traversal LeetCode:{' '} &#35;230

Given the root of a binary search tree and an integer k, return the kth smallest value in the tree.

Input: root = [3,1,4,null,2], k = 1
Output: 1

Approach: Inorder traversal of a BST visits nodes in ascending order. Traverse inorder while counting visited nodes, stopping and returning the value when the count reaches k. Complexity: Time O(h + k) · Space O(h) Follow-up: What if the BST is modified (insert/delete) frequently and you need kth smallest repeatedly?


39. Construct Binary Tree from Preorder and Inorder Traversal Medium

Onsite Tree · Divide and Conquer LeetCode:{' '} &#35;105

Given two integer arrays, preorder and inorder, representing the preorder and inorder traversal of a binary tree, construct and return the binary tree.

Input: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7]
Output: [3,9,20,null,null,15,7]

Approach: The first element of preorder is always the root. Find that value's index in inorder to split the tree into left and right subtrees, then recurse. Use a HashMap for O(1) index lookups in inorder. Complexity: Time O(n) · Space O(n) Follow-up: Do the same using postorder and inorder traversals instead.


40. Design an Inventory Management Service Hard

Onsite · LLD OOP · Design · Concurrency

Meesho's most frequently reported machine coding question. Design a service for a reseller marketplace that supports adding products, adding stock, blocking stock when a checkout starts, releasing blocked stock on payment failure, and confirming a sale on payment success.

System.addProduct(sku, name), addStock(sku, qty)
System.blockStock(sku, qty, orderId) // during checkout
System.confirmSale(orderId) // on payment success
System.releaseBlockedStock(orderId) // on payment failure/timeout

Approach: Classes: Product (sku, name), Inventory (sku → availableQty, blockedQty). blockStock() atomically moves quantity from available to blocked (reject if insufficient available stock) and records a BlockRecord keyed by orderId. confirmSale() removes the blocked quantity permanently. releaseBlockedStock() moves blocked quantity back to available. Use a lock per SKU (or a database row-level lock / optimistic concurrency with a version column) to prevent race conditions when multiple orders block the same SKU concurrently. Key Design Principles: Concurrency-safe stock updates, Single Responsibility (separate Inventory from Product), idempotent confirm/release using orderId Follow-up: How would you handle a blocked stock request that never confirms or releases (e.g. the user closes the tab mid-payment)? Discuss a TTL-based auto-release job.


41. Design a Social Feed (Follow, Post, Paginated Top-K Feed) Hard

Onsite · LLD OOP · Design · Pagination

Design a Twitter/Instagram-style system where users can follow other users, create posts, and fetch a paginated feed showing the top K most recent posts from the people they follow.

System.follow(userId, followeeId), unfollow(userId, followeeId)
System.createPost(userId, content) → postId
System.getFeed(userId, pageSize, cursor) → List<Post>

Approach: Classes: User (with a set of followees), Post (id, authorId, content, timestamp). Naive approach: on getFeed, fetch posts from all followees and merge-sort by timestamp, this is a k-way merge using a min-heap of size = number of followees, each holding that followee's latest unconsumed post. For pagination, use a cursor encoding the last seen (timestamp, postId) pair rather than an offset, since offsets break when new posts are inserted. Key Design Principles: K-way merge with a heap for feed generation, cursor-based (not offset-based) pagination, separation of Post storage from Feed generation logic Follow-up: At Meesho scale (millions of users), a pull-based feed is too slow. Discuss push-based fan-out (write the post into every follower's feed at post-time) and the hybrid approach for celebrity accounts with millions of followers.


42. Design a Doctor Appointment / Slot Booking System Medium

Onsite · LLD OOP · Design · Scheduling

Design a system where doctors register with a name and specialization, define their availability in fixed 30-minute slots, and patients can search for and book an available slot with a doctor.

System.registerDoctor(name, specialization)
System.addAvailability(doctorId, date, startTime, endTime) // splits into 30-min slots
System.getAvailableSlots(doctorId, date) → List<Slot>
System.bookSlot(doctorId, slotId, patientId) → Booking

Approach: Classes: Doctor, Slot (doctorId, date, startTime, endTime, status: AVAILABLE/BOOKED), Booking (slotId, patientId, status). addAvailability() splits the given time range into discrete 30-minute Slot objects. bookSlot() must atomically check-and-set the slot status from AVAILABLE to BOOKED to prevent double-booking under concurrent requests (optimistic locking with a version field, or a DB unique constraint on slotId+status). Key Design Principles: Atomic check-and-set for booking to prevent double-booking, clean separation of Doctor/Slot/Booking entities, Strategy pattern if supporting multiple slot durations later Follow-up: How would you support recurring weekly availability instead of one-off date ranges, without pre-generating slots years in advance?


43. Design a Rate Limiter Medium

Onsite · LLD OOP · Design · Concurrency

Design a rate limiter that allows at most N requests per user within a rolling time window of T seconds, rejecting requests beyond that limit.

RateLimiter.allowRequest(userId) → boolean

Approach: Sliding Window Log or Sliding Window Counter algorithm. For the log approach, maintain a per-user queue of request timestamps; on each request, evict timestamps older than T seconds from the front, then allow if the remaining count is below N. For scale, use Redis sorted sets (ZADD + ZREMRANGEBYSCORE) keyed by userId so the limiter works across multiple application servers. Key Design Principles: Sliding window over fixed window (avoids burst-at-boundary issues), Redis for a distributed, multi-server-safe implementation Follow-up: Compare Token Bucket vs Sliding Window for this use case, and when you would pick one over the other.


44. Design a Notification Service Medium

Onsite · LLD OOP · Design · Strategy Pattern

Design a service that can send notifications to users via multiple channels (SMS, Push, Email), where the channel(s) used can vary per notification type and per user preference.

NotificationService.send(userId, message, type) // type: ORDER_UPDATE, PROMOTION, etc.
User has channel preferences: [SMS, PUSH, EMAIL]

Approach: Define a NotificationChannel interface with implementations SmsChannel, PushChannel, EmailChannel (Strategy pattern). NotificationService looks up the user's preferred channels and the notification type's allowed channels, sends via the intersection. Use a Factory to instantiate the right channel objects, and a queue (e.g. Kafka) between the trigger and the actual send so a slow channel provider does not block the caller. Key Design Principles: Strategy pattern for channels, Factory for channel instantiation, async dispatch via a queue for resilience to provider slowness Follow-up: How do you handle a user who has opted out of PROMOTION notifications but should still receive ORDER_UPDATE ones on the same channel?


45. Design Meesho's Product Catalog & Search System Hard

Onsite · HLD System Design

Design the product catalog and search service for a reseller marketplace with millions of products from thousands of suppliers, where prices and stock change frequently and search must stay fast during high-traffic sale events.

Functional: searchProducts(query, filters), getProduct(productId), updatePriceAndStock(productId)
Non-functional: <150ms search latency, 10M+ products, price/stock updates visible within seconds, resilient to 10x traffic during sale events

Approach: Write path: supplier updates go to a primary database (sharded by category/supplier), then change events publish to Kafka. Read path: Elasticsearch indexes product data for full-text + filtered search; a Kafka consumer keeps the index in near-real-time sync. Redis caches hot product detail pages and category listing pages with a short TTL. During sale events, pre-warm caches and use read replicas to absorb the read spike; writes to stock are funneled through the Inventory service (see the LLD question above) to stay consistent under concurrent checkouts. Key Design Principles: CQRS separation of write (DB + Kafka) and read (Elasticsearch + Redis) paths, eventual consistency for search freshness, cache pre-warming for predictable traffic spikes Follow-up: How do you prevent overselling a product with only 2 units left when 500 concurrent users are trying to check out during a flash sale?


46. Design Meesho's Order Management & Fulfillment System Hard

Onsite · HLD System Design

Design the backend that takes an order from checkout through supplier fulfillment, shipping, and delivery, tracking state transitions and notifying the reseller and end customer at each step.

Functional: createOrder(cartId), updateOrderStatus(orderId, status), getOrderStatus(orderId)
Non-functional: exactly-once status transitions, 100K+ orders/day, status changes reflected to users within seconds

Approach: Model the order as a state machine (PLACED → CONFIRMED → SHIPPED → OUT_FOR_DELIVERY → DELIVERED, with CANCELLED/RETURNED branches). Each transition is an event published to Kafka, partitioned by orderId to guarantee ordering per order. Downstream consumers (Notification Service, Analytics, Reseller Payout) subscribe independently. Use a database with a unique constraint plus idempotency keys on transition events to guarantee exactly-once processing even if the same event is redelivered. Key Design Principles: State machine modeling for order lifecycle, Kafka partitioning by orderId for ordering guarantees, idempotency keys for exactly-once semantics Follow-up: A supplier marks an order SHIPPED, but the shipping partner's webhook for OUT_FOR_DELIVERY never arrives. How do you detect and recover from missing state transitions?


47. Design a Reseller Commission and Payout System Hard

Onsite · HLD System Design

Design the backend that calculates each reseller's commission on completed orders and processes periodic payouts, handling returns and cancellations that must claw back already-calculated commission.

Functional: calculateCommission(orderId), processPayoutBatch(resellerId, period), handleReturn(orderId)
Non-functional: financially auditable (every calculation must be traceable), no double payouts, handle returns up to 30 days after delivery

Approach: Commission is calculated as an immutable ledger entry (append-only) triggered by an order reaching DELIVERED, referencing the orderId and a commission snapshot (rate, base amount). A scheduled batch job aggregates ledger entries per reseller per payout period and initiates a payout, marking those ledger entries as PAID with a payoutBatchId. A return/cancellation after payout creates a new negative ledger entry (clawback) rather than mutating the original, deducted from the reseller's next payout cycle. Key Design Principles: Append-only ledger for auditability (never mutate past entries), idempotent payout batching keyed by period, clawback via new entries instead of edits Follow-up: How do you handle a reseller whose clawback exceeds their next payout amount (net negative balance)?


48. Merge k Sorted Lists Hard

Onsite Linked List · Heap · Divide and Conquer LeetCode:{' '} &#35;23

You are given an array of k linked lists, each sorted in ascending order. Merge all the linked lists into one sorted linked list and return it.

Input: lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]

Approach: Use a min-heap holding the current head node of each list. Repeatedly pop the smallest node, append it to the result, and push its next node (if any) back into the heap. Divide-and-conquer (pairwise merging) is an alternative with the same complexity. Complexity: Time O(n log k) (n = total nodes, k = number of lists) · Space O(k) Follow-up: What if the lists are extremely large and cannot fit in memory (external merge)?


49. Maximum Product Subarray Medium

Onsite Dynamic Programming · Array LeetCode:{' '} &#35;152

Given an integer array, find a contiguous subarray with the largest product, and return that product.

Input: nums = [2,3,-2,4]
Output: 6
Explanation: [2,3] has the largest product 6.

Approach: Track both the maximum and minimum product ending at the current index (since a negative number can flip a very negative product into the new maximum). Update both at every step and track the overall maximum. Complexity: Time O(n) · Space O(1) Follow-up: Return the actual subarray, not just the product value.


50. Find the Duplicate Number Medium

Onsite Array · Binary Search · Cycle Detection LeetCode:{' '} &#35;287

Given an array of n+1 integers where each integer is between 1 and n inclusive, there is exactly one duplicate number. Find it without modifying the array and using only O(1) extra space.

Input: nums = [1,3,4,2,2]
Output: 2

Approach: Treat the array as a linked list where index i points to nums[i]. Since there's a duplicate, this creates a cycle. Use Floyd's cycle detection (slow/fast pointers) to find the cycle entry point, which is the duplicate number. Complexity: Time O(n) · Space O(1) Follow-up: What if there could be multiple duplicate numbers, and you need to find all of them?


Preparation Tips

Meesho's process is DSA-heavy across two live coding rounds, with arrays, graphs, and dynamic programming appearing most often, alongside a strong emphasis on core CS fundamentals (OS, CN, Java/C++) in the OA's MCQ section. For backend and SDE-2 roles, the Machine Coding/LLD round carries real weight, practice a clean, working Inventory Management System end to end before your interview, since it is the single most frequently reported design question. For System Design rounds, think in terms of Meesho's actual domain: product catalog at scale, order state machines, and reseller payouts, rather than generic feed/social examples.

Join Telegram group to get the latest Meesho OA questions and connect with candidates currently in the Meesho interview process.

Useful Resources