Zepto Coding Round Questions with Solutions
Last updated 2026-11-19
A quick-commerce company lives or dies by what sits on the shelves of a small warehouse and how fast a rider can leave with a bag. Candidate reports about Zepto's SDE-1 process mention data structures problems at a brisk pace and a design-flavoured discussion, so the eleven tasks below are built from that setting: stock that expires, aisles that are laid out in odd ways, and bags and riders with hard limits.
These are original practice problems, not a record of any test. Read Zepto interview questions for the wider technical and HR round, and the DSA coding round guide for how to pace a timed screen. Sourced hiring news lives at Zepto hiring.
What a dark store teaches you about problem types
Inventory problems are mostly counting and ordering problems: do we have enough, which batch goes first, how do bulk updates land on a shelf. Layout problems are search and graph problems on a grid. Capacity problems are binary search on the answer or knapsack. Once you map a story to one of those families the code is short.
Speed is the theme. Reports describe a screen where the plain solution is rarely enough and the interviewer asks for the version that scales, so for each task below it helps to state the brute-force cost, then the improved one, then write the improved one directly.
Habits that save minutes
- Name the invariant before the loop: what is true about the heap, window or range at the top of each iteration.
- Test with an empty input, a single element and a case where everything ties.
- Keep helper functions small so a bug can be located by reading three lines, not thirty.
Hiring status
Sourced hiring news for Zepto is collected at Zepto hiring, and current roles are on the company's careers page at zeptonow.com/careers. The round shapes described above are candidate-reported.
Zepto Coding Round Questions with Solutions: questions with worked answers
1 Check whether a dark store can fulfil a basket and report which items fall short.
easyCount the units requested per item and compare with the units in stock. Any item where demand exceeds stock goes into the shortfall map with the missing quantity. One pass over the basket plus lookups, so O(n) time and O(distinct items) space. Common mistakes: using a set, which ignores quantities, and raising an error for an item the store has never stocked instead of treating its stock as zero.
pythonfrom collections import Counter def shortfall(stock, basket): want = Counter(basket) return {item: n - stock.get(item, 0) for item, n in want.items() if n > stock.get(item, 0)}javaimport java.util.*; class Store { static Map<String, Integer> shortfall(Map<String, Integer> stock, List<String> basket) { Map<String, Integer> want = new HashMap<>(); for (String item : basket) want.merge(item, 1, Integer::sum); Map<String, Integer> missing = new TreeMap<>(); for (Map.Entry<String, Integer> e : want.entrySet()) { int have = stock.getOrDefault(e.getKey(), 0); if (e.getValue() > have) missing.put(e.getKey(), e.getValue() - have); } return missing; } }2 Pick units for an order so that the batches closest to expiry are used first.
mediumFirst-expired-first-out: sort batches by expiry date, then take from each in turn until the requested quantity is met. Return the plan as (expiry, units) pairs, or nothing if total stock cannot cover the order. O(b log b) time for b batches, O(b) space. Common mistakes: taking from the largest batch first, which leaves small ones to expire, and mutating stock before knowing the order can be filled.
pythondef fefo_plan(batches, qty): plan = [] for expiry, units in sorted(batches): if qty == 0: break take = min(units, qty) plan.append((expiry, take)) qty -= take return plan if qty == 0 else Nonejavaimport java.util.*; class Fefo { static List<int[]> plan(int[][] batches, int qty) { int[][] sorted = batches.clone(); Arrays.sort(sorted, (a, b) -> Integer.compare(a[0], b[0])); List<int[]> out = new ArrayList<>(); for (int[] b : sorted) { if (qty == 0) break; int take = Math.min(b[1], qty); out.add(new int[]{b[0], take}); qty -= take; } return qty == 0 ? out : null; } }3 Locate a bin code in an aisle list that was sorted and then rotated.
mediumBinary search with one extra decision. At each step, one half of the range is still sorted. Check whether the target lies inside that sorted half and discard the other half accordingly. O(log n) time, O(1) space. Common mistakes: comparing against the wrong end of the sorted half, using a strict inequality that skips the boundary element, and not handling duplicates (which degrades the worst case to linear).
pythondef find_bin(codes, target): lo, hi = 0, len(codes) - 1 while lo <= hi: mid = (lo + hi) // 2 if codes[mid] == target: return mid if codes[lo] <= codes[mid]: if codes[lo] <= target < codes[mid]: hi = mid - 1 else: lo = mid + 1 else: if codes[mid] < target <= codes[hi]: lo = mid + 1 else: hi = mid - 1 return -1javaclass Aisle { static int findBin(int[] a, int target) { int lo = 0, hi = a.length - 1; while (lo <= hi) { int mid = (lo + hi) >>> 1; if (a[mid] == target) return mid; if (a[lo] <= a[mid]) { if (a[lo] <= target && target < a[mid]) hi = mid - 1; else lo = mid + 1; } else { if (a[mid] < target && target <= a[hi]) lo = mid + 1; else hi = mid - 1; } } return -1; } }4 Pack the most valuable set of items into a delivery bag with a weight limit.
mediumClassic 0/1 knapsack. best[c] is the highest value achievable with capacity c. For each item, walk capacities downward so the item is used at most once, and set best[c] = max(best[c], best[c - w] + v). O(n * cap) time, O(cap) space. Common mistakes: iterating capacity upward, which silently turns it into unbounded knapsack, and returning best of the wrong index when the bag need not be exactly full.
pythondef best_bag(items, cap): best = [0] * (cap + 1) for weight, value in items: for c in range(cap, weight - 1, -1): best[c] = max(best[c], best[c - weight] + value) return best[cap]javaclass Bag { static int best(int[] w, int[] v, int cap) { int[] best = new int[cap + 1]; for (int i = 0; i < w.length; i++) for (int c = cap; c >= w[i]; c--) best[c] = Math.max(best[c], best[c - w[i]] + v[i]); return best[cap]; } }5 A picker must wait n slots before handling the same zone again. Find the least time to clear all tasks.
mediumOnly the most frequent zone forces idle time. Arrange its copies as frames of width n+1: (maxFreq - 1) full frames plus a last row holding every zone tied for the maximum. The answer is the larger of that value and the number of tasks, since enough variety removes all idling. O(n) time, O(1) space for 26 zones. Common mistakes: simulating with a heap when a formula suffices, and forgetting the ties on the last row.
pythonfrom collections import Counter def least_time(zones, cooldown): counts = Counter(zones) top = max(counts.values()) ties = sum(1 for v in counts.values() if v == top) return max(len(zones), (top - 1) * (cooldown + 1) + ties)javaclass Picker { static int leastTime(char[] zones, int cooldown) { int[] cnt = new int[26]; int top = 0; for (char z : zones) top = Math.max(top, ++cnt[z - 'A']); int ties = 0; for (int c : cnt) if (c == top) ties++; return Math.max(zones.length, (top - 1) * (cooldown + 1) + ties); } }6 For every cell of a city grid, find the walking distance to the nearest dark store.
mediumMulti-source breadth-first search. Put every store in the queue at distance zero, then expand outward one ring at a time; the first time a cell is reached is its shortest distance. One pass over the grid, O(rows*cols) time and space. Common mistakes: running a separate BFS from each cell, which is quadratic, and failing to mark cells as seen when they are enqueued.
pythonfrom collections import deque def distance_to_store(grid): rows, cols = len(grid), len(grid[0]) dist = [[-1] * cols for _ in range(rows)] queue = deque() for r in range(rows): for c in range(cols): if grid[r][c] == 1: dist[r][c] = 0 queue.append((r, c)) while queue: r, c = queue.popleft() for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)): nr, nc = r + dr, c + dc if 0 <= nr < rows and 0 <= nc < cols and dist[nr][nc] == -1: dist[nr][nc] = dist[r][c] + 1 queue.append((nr, nc)) return distjavaimport java.util.*; class Stores { static int[][] distance(int[][] g) { int R = g.length, C = g[0].length; int[][] dist = new int[R][C]; ArrayDeque<int[]> q = new ArrayDeque<>(); for (int r = 0; r < R; r++) for (int c = 0; c < C; c++) { dist[r][c] = g[r][c] == 1 ? 0 : -1; if (g[r][c] == 1) q.add(new int[]{r, c}); } int[] dr = {1, -1, 0, 0}, dc = {0, 0, 1, -1}; while (!q.isEmpty()) { int[] cur = q.poll(); for (int k = 0; k < 4; k++) { int nr = cur[0] + dr[k], nc = cur[1] + dc[k]; if (nr >= 0 && nr < R && nc >= 0 && nc < C && dist[nr][nc] == -1) { dist[nr][nc] = dist[cur[0]][cur[1]] + 1; q.add(new int[]{nr, nc}); } } } return dist; } }7 Apply many shelf restock updates, each adding units to a range of shelves, and report the final counts.
mediumUse a difference array. For an update that adds v to shelves l through r, add v at index l and subtract v at index r+1. A single prefix-sum pass then yields every shelf's final value. O(n + u) time for u updates, O(n) space. Common mistakes: looping over the whole range for each update (O(n*u)), and an off-by-one at r+1 when r is the last shelf, which needs a spare slot.
pythondef apply_restocks(n, updates): diff = [0] * (n + 1) for left, right, add in updates: diff[left] += add diff[right + 1] -= add out, running = [], 0 for i in range(n): running += diff[i] out.append(running) return outjavaclass Restock { static int[] apply(int n, int[][] updates) { int[] diff = new int[n + 1]; for (int[] u : updates) { diff[u[0]] += u[2]; diff[u[1] + 1] -= u[2]; } int[] out = new int[n]; int running = 0; for (int i = 0; i < n; i++) { running += diff[i]; out[i] = running; } return out; } }8 Find the smallest bag capacity that lets a rider deliver all parcels, in order, within d trips.
mediumBinary search on the capacity. The lowest possible value is the heaviest parcel and the highest is the total weight. For a candidate capacity, greedily load parcels in order and count trips. If trips are within d the capacity works, so search lower; otherwise search higher. O(n log(sum)) time, O(1) space. Common mistakes: starting the lower bound at 1, which makes the greedy check fail, and reordering parcels when the order is fixed.
pythondef min_capacity(weights, d): def trips(cap): count, load = 1, 0 for w in weights: if load + w > cap: count += 1 load = 0 load += w return count lo, hi = max(weights), sum(weights) while lo < hi: mid = (lo + hi) // 2 if trips(mid) <= d: hi = mid else: lo = mid + 1 return lojavaclass Capacity { static int minCapacity(int[] w, int d) { int lo = 0, hi = 0; for (int x : w) { lo = Math.max(lo, x); hi += x; } while (lo < hi) { int mid = (lo + hi) >>> 1; if (trips(w, mid) <= d) hi = mid; else lo = mid + 1; } return lo; } private static int trips(int[] w, int cap) { int count = 1, load = 0; for (int x : w) { if (load + x > cap) { count++; load = 0; } load += x; } return count; } }9 Choose two products whose combined price is as high as possible without going over a customer's budget.
easySort the prices and use two pointers from both ends. If the pair's sum is over budget, move the right pointer down; otherwise record it and move the left pointer up to look for a larger sum. O(n log n) time for the sort, O(1) extra space. Common mistakes: moving both pointers at once and skipping the optimum, and returning zero instead of a clear not-possible value.
pythondef best_pair(prices, budget): p = sorted(prices) lo, hi, best = 0, len(p) - 1, -1 while lo < hi: s = p[lo] + p[hi] if s > budget: hi -= 1 else: best = max(best, s) lo += 1 return bestjavaimport java.util.*; class Pair { static int bestPair(int[] prices, int budget) { int[] p = prices.clone(); Arrays.sort(p); int lo = 0, hi = p.length - 1, best = -1; while (lo < hi) { int s = p[lo] + p[hi]; if (s > budget) hi--; else { best = Math.max(best, s); lo++; } } return best; } }10 Find the longest run of consecutive SKU numbers in an unsorted catalogue.
mediumPut all numbers in a hash set. Only start counting from a number whose predecessor is absent, then walk upward while the next number exists. Every number is visited at most twice, giving O(n) time and O(n) space. Common mistakes: sorting (which costs O(n log n) and is usually rejected when the O(n) route is asked for), and counting from every element, which becomes quadratic on a long run.
pythondef longest_run(skus): seen = set(skus) best = 0 for s in seen: if s - 1 not in seen: end = s while end + 1 in seen: end += 1 best = max(best, end - s + 1) return bestjavaimport java.util.*; class Skus { static int longestRun(int[] skus) { Set<Integer> seen = new HashSet<>(); for (int s : skus) seen.add(s); int best = 0; for (int s : seen) { if (!seen.contains(s - 1)) { int end = s; while (seen.contains(end + 1)) end++; best = Math.max(best, end - s + 1); } } return best; } }11 Design a dispatcher that always assigns a new order to the rider with the fewest active orders.
hardKeep each rider's load in a map and a min-heap of (load, rider) entries. To assign, pop entries until one matches the current load (stale entries are discarded lazily), bump the load and push the new entry. When a delivery completes, decrement the load and push a fresh entry. Each operation is O(log r) amortised. Common mistakes: updating a heap entry in place, which breaks the heap, and not breaking ties deterministically.
pythonimport heapq class Dispatcher: def __init__(self, riders): self.load = {r: 0 for r in riders} self.heap = [(0, r) for r in riders] heapq.heapify(self.heap) def assign(self): while True: load, rider = heapq.heappop(self.heap) if self.load[rider] == load: break self.load[rider] += 1 heapq.heappush(self.heap, (load + 1, rider)) return rider def complete(self, rider): self.load[rider] -= 1 heapq.heappush(self.heap, (self.load[rider], rider))javaimport java.util.*; class Dispatcher { private final int[] load; private final PriorityQueue<int[]> heap = new PriorityQueue<>((a, b) -> a[0] != b[0] ? Integer.compare(a[0], b[0]) : Integer.compare(a[1], b[1])); Dispatcher(int riders) { load = new int[riders]; for (int r = 0; r < riders; r++) heap.add(new int[]{0, r}); } int assign() { int[] top; do { top = heap.poll(); } while (load[top[1]] != top[0]); load[top[1]]++; heap.add(new int[]{load[top[1]], top[1]}); return top[1]; } void complete(int rider) { load[rider]--; heap.add(new int[]{load[rider], rider}); } }
Frequently asked questions
What do Zepto coding rounds usually test?
Candidate-reported accounts mention arrays, strings, hashing, heaps, graphs and dynamic programming at a quick pace, and sometimes a short design discussion. Treat the problems here as practice in that style, not as a forecast.
Should I write the brute force first?
Say it in one sentence and its cost, then go straight to the better approach if you can see it. If you are not sure, code the brute force first so you have a correct baseline, and improve it with the time left.
Why do so many answers here use heaps and binary search?
Allocation, nearest-first and capacity questions fit those tools naturally. Knowing when a problem is asking for the smallest feasible value is half the work in a quick-commerce setting.
How can I practise the dispatcher-style design task?
Set a one-hour timer, write the class with two or three operations, add a few tests, then explain what would change with thousands of riders. The lazy-deletion heap in this page is a good talking point.
Where do I find official Zepto hiring information?
Use the company's careers page at zeptonow.com/careers and the Zepto hiring page on this site for sourced news.
Sources
Related guides
More in Company Interview Questions
- Zepto Interview Questions and Answers
- Zerodha Coding Round Questions With Solutions
- Zerodha Interview Questions and Answers
- Zoho Coding Round Questions with Solutions
- Zoho Interview Questions and Answers
- Zomato Coding Round Questions with Solutions
- Zomato Interview Questions and Answers
- ZS Associates Coding and Case Logic Questions
- ZS Associates Interview Questions with Answers
- Accenture Coding Round Questions with Solutions
- Accenture Interview Questions for Freshers
- Adobe Coding Round Questions with Solutions in Python and Java