Zomato Coding Round Questions with Solutions
Last updated 2026-11-19
Zomato's product is a ranked list: which restaurants to show, in what order, for whom, right now. The problems in this set take that idea literally. You will rank by a vote-aware score, merge result lists coming from different zones, walk a menu category tree, and find the busiest stretch in a stream of orders.
They are original practice problems written in the style of what candidate accounts describe, and they are not copies of any test. For the wider interview, including the HR side, see Zomato interview questions. To plan a timed screen, read the DSA coding round guide. Sourced news is at Zomato hiring.
Ranking is the recurring theme
Reports of Zomato interviews mention on-campus coding with arrays, strings, trees and dynamic programming, and a separate UI-focused round for front-end roles. Whatever the role, ranking and ordering show up often: compare by several keys, break ties deterministically and avoid sorting more than you need to.
A useful warm-up is to take any problem below and answer three questions before coding. What is the sort key? What happens on a tie? What changes if the list is ten million long and only the top ten matter?
A note on the front-end track
Candidates for UI roles report being asked about browser behaviour and component design alongside problem solving. The problems on this page are language-agnostic algorithm practice and will not cover DOM or framework questions, so add those separately if you are applying to a front-end role.
Hiring status
The company lists its own roles at zomato.com/careers, and Zomato hiring on this site gathers sourced news. The round structure described here is candidate-reported and varies between teams.
Zomato Coding Round Questions with Solutions: questions with worked answers
1 Rank restaurants so that a place with one perfect review does not beat a place with thousands of good ones.
mediumUse a damped (Bayesian) average. Score = (votes * rating + m * overall_mean) / (votes + m), where m is the number of votes you need before trusting a rating. Few votes pull the score toward the mean. Sort by descending score, break ties by name. O(n log n), or O(n log k) with a heap for the top k. Common mistakes: ranking by raw rating, and choosing m so large that nothing moves.
pythonimport heapq def top_by_score(places, k, m=50, mean=3.5): def score(p): _, rating, votes = p return (votes * rating + m * mean) / (votes + m) best = heapq.nsmallest(k, places, key=lambda p: (-score(p), p[0])) return [p[0] for p in best]javaimport java.util.*; class Ranking { static List<String> top(String[] name, double[] rating, int[] votes, int k, int m, double mean) { Integer[] idx = new Integer[name.length]; double[] score = new double[name.length]; for (int i = 0; i < idx.length; i++) { idx[i] = i; score[i] = (votes[i] * rating[i] + m * mean) / (votes[i] + m); } Arrays.sort(idx, (a, b) -> score[a] != score[b] ? Double.compare(score[b], score[a]) : name[a].compareTo(name[b])); List<String> out = new ArrayList<>(); for (int i = 0; i < Math.min(k, idx.length); i++) out.add(name[idx[i]]); return out; } }2 Merge k already-sorted result lists from different delivery zones into one sorted list.
mediumKeep a min-heap holding the current head of every list, as (value, list index, position). Pop the smallest, append it, and push the next element from the same list. O(N log k) for N total items, O(k) extra space. Common mistakes: concatenating and re-sorting (O(N log N)), and omitting the list index so equal values cannot be compared.
pythonimport heapq def merge_lists(lists): heap = [(lst[0], i, 0) for i, lst in enumerate(lists) if lst] heapq.heapify(heap) out = [] while heap: value, i, pos = heapq.heappop(heap) out.append(value) if pos + 1 < len(lists[i]): heapq.heappush(heap, (lists[i][pos + 1], i, pos + 1)) return outjavaimport java.util.*; class MergeZones { static List<Integer> merge(List<int[]> lists) { PriorityQueue<int[]> heap = new PriorityQueue<>((a, b) -> a[0] != b[0] ? Integer.compare(a[0], b[0]) : Integer.compare(a[1], b[1])); for (int i = 0; i < lists.size(); i++) if (lists.get(i).length > 0) heap.add(new int[]{lists.get(i)[0], i, 0}); List<Integer> out = new ArrayList<>(); while (!heap.isEmpty()) { int[] top = heap.poll(); out.add(top[0]); int[] src = lists.get(top[1]); if (top[2] + 1 < src.length) heap.add(new int[]{src[top[2] + 1], top[1], top[2] + 1}); } return out; } }3 Find the contiguous run of days with the best total change in orders.
easyKadane's algorithm. Track the best sum of a run ending at the current day: either extend the previous run or start fresh at the current value. Keep the maximum seen. O(n) time, O(1) space. Common mistakes: initialising the best to zero, which returns the wrong answer when every value is negative, and confusing the run's sum with its length.
pythondef best_run(changes): ending = best = changes[0] for x in changes[1:]: ending = max(x, ending + x) best = max(best, ending) return bestjavaclass Spike { static int bestRun(int[] c) { int ending = c[0], best = c[0]; for (int i = 1; i < c.length; i++) { ending = Math.max(c[i], ending + c[i]); best = Math.max(best, ending); } return best; } }4 What is the largest number of restaurants open at the same moment, given opening and closing times?
mediumSweep line. Turn each restaurant into two events, an opening (+1) and a closing (-1), sort them by time with closings first on ties, then scan while keeping a running count. The peak is the answer. O(n log n) time, O(n) space. Common mistakes: putting openings before closings at the same minute, which counts two restaurants that never overlap, and treating times that cross midnight as ordinary intervals.
pythondef peak_open(hours): events = [] for opens, closes in hours: events.append((opens, 1)) events.append((closes, -1)) events.sort() now = peak = 0 for _, delta in events: now += delta peak = max(peak, now) return peakjavaimport java.util.*; class Open { static int peak(int[][] hours) { int[][] ev = new int[hours.length * 2][]; for (int i = 0; i < hours.length; i++) { ev[2 * i] = new int[]{hours[i][0], 1}; ev[2 * i + 1] = new int[]{hours[i][1], -1}; } Arrays.sort(ev, (a, b) -> a[0] != b[0] ? Integer.compare(a[0], b[0]) : Integer.compare(a[1], b[1])); int now = 0, peak = 0; for (int[] e : ev) { now += e[1]; peak = Math.max(peak, now); } return peak; } }5 Group dishes that are made from exactly the same set of ingredients.
easyUse a canonical key: the sorted tuple of a dish's ingredients. Dishes with equal keys fall in the same bucket of a hash map. O(n * k log k) for n dishes with k ingredients each, O(n * k) space. Common mistakes: using an unsorted list as the key, joining ingredient names with no separator so that different sets collide, and forgetting that duplicates inside a dish may or may not matter.
pythonfrom collections import defaultdict def same_ingredients(dishes): groups = defaultdict(list) for name, ingredients in dishes: groups[tuple(sorted(ingredients))].append(name) return sorted(sorted(g) for g in groups.values())javaimport java.util.*; class Dishes { static Collection<List<String>> group(String[] names, String[][] ingredients) { Map<String, List<String>> groups = new TreeMap<>(); for (int i = 0; i < names.length; i++) { String[] copy = ingredients[i].clone(); Arrays.sort(copy); groups.computeIfAbsent(String.join("|", copy), k -> new ArrayList<>()).add(names[i]); } return groups.values(); } }6 Choose promotion slots to maximise reach when two adjacent slots cannot both be used.
mediumDynamic programming over slots. For each slot you either skip it and keep the best so far, or take it plus the best from two slots back. Keeping just two running values gives O(n) time and O(1) space. Common mistakes: a greedy pick of the biggest slot first, which fails on inputs like 3, 5, 3, and mishandling arrays of length zero or one.
pythondef best_reach(slots): skip, take = 0, 0 for s in slots: skip, take = max(skip, take), skip + s return max(skip, take)javaclass Promo { static int bestReach(int[] slots) { int skip = 0, take = 0; for (int s : slots) { int newTake = skip + s; skip = Math.max(skip, take); take = newTake; } return Math.max(skip, take); } }7 Print a menu's category tree level by level.
easyBreadth-first traversal with a queue. At each round, process exactly as many nodes as the queue held at the start; those are one level. Push their children for the next round. O(n) time, O(width) space. Common mistakes: using a stack, which gives depth-first order, and not freezing the level size before the inner loop.
pythonfrom collections import deque class Category: def __init__(self, name, children=None): self.name = name self.children = children or [] def levels(root): out, queue = [], deque([root]) while queue: out.append([c.name for c in queue]) for _ in range(len(queue)): node = queue.popleft() queue.extend(node.children) return outjavaimport java.util.*; class Category { String name; List<Category> children = new ArrayList<>(); Category(String name) { this.name = name; } static List<List<String>> levels(Category root) { List<List<String>> out = new ArrayList<>(); Deque<Category> q = new ArrayDeque<>(); q.add(root); while (!q.isEmpty()) { List<String> level = new ArrayList<>(); for (int i = q.size(); i > 0; i--) { Category c = q.poll(); level.add(c.name); q.addAll(c.children); } out.add(level); } return out; } }8 Measure how similar two past orders are by the longest common subsequence of their item lists.
mediumDynamic programming. dp[i][j] is the length of the longest common subsequence of the first i items of one order and the first j of the other. Equal items extend the diagonal by one, otherwise take the larger of left and up. O(m*n) time, and two rows are enough for O(n) space. Common mistakes: confusing it with the longest common substring, which needs contiguous items, and resetting to zero on a mismatch.
pythondef common_items(a, b): prev = [0] * (len(b) + 1) for x in a: cur = [0] for j, y in enumerate(b, 1): cur.append(prev[j - 1] + 1 if x == y else max(prev[j], cur[j - 1])) prev = cur return prev[-1]javaclass Similar { static int commonItems(String[] a, String[] b) { int[] prev = new int[b.length + 1]; for (String x : a) { int[] cur = new int[b.length + 1]; for (int j = 1; j <= b.length; j++) cur[j] = x.equals(b[j - 1]) ? prev[j - 1] + 1 : Math.max(prev[j], cur[j - 1]); prev = cur; } return prev[b.length]; } }9 Report the maximum number of orders in every window of w consecutive minutes.
hardMonotonic deque of indices whose values are in decreasing order. Before adding index i, drop indices from the back whose value is not larger, and drop the front if it has left the window. The front is then the window maximum. Each index enters and leaves once, so O(n) time, O(w) space. Common mistakes: scanning each window for O(n*w), and storing values rather than indices, which makes expiry impossible to test.
pythonfrom collections import deque def window_max(orders, w): dq, out = deque(), [] for i, v in enumerate(orders): while dq and orders[dq[-1]] <= v: dq.pop() dq.append(i) if dq[0] <= i - w: dq.popleft() if i >= w - 1: out.append(orders[dq[0]]) return outjavaimport java.util.*; class Window { static int[] max(int[] a, int w) { int[] out = new int[a.length - w + 1]; Deque<Integer> dq = new ArrayDeque<>(); for (int i = 0; i < a.length; i++) { while (!dq.isEmpty() && a[dq.peekLast()] <= a[i]) dq.pollLast(); dq.addLast(i); if (dq.peekFirst() <= i - w) dq.pollFirst(); if (i >= w - 1) out[i - w + 1] = a[dq.peekFirst()]; } return out; } }10 Order search results by rating (high first), then delivery time (low first), then name.
easyUse a multi-key comparator. Negate the rating in a tuple key in Python, or chain comparators in Java. The sort is stable and deterministic. O(n log n) time. Common mistakes: sorting by one key and then re-sorting by another, which discards the first ordering unless the sort is stable and applied in reverse order, and comparing floating-point ratings with equality after arithmetic.
pythondef order_results(places): return sorted(places, key=lambda p: (-p['rating'], p['eta'], p['name']))javaimport java.util.*; class Results { static class Place { String name; double rating; int eta; Place(String name, double rating, int eta) { this.name = name; this.rating = rating; this.eta = eta; } } static void order(List<Place> places) { places.sort(Comparator.<Place>comparingDouble(p -> -p.rating) .thenComparingInt(p -> p.eta) .thenComparing(p -> p.name)); } }
Frequently asked questions
What are Zomato coding rounds like?
Candidate-reported accounts describe on-campus rounds with arrays, strings, heaps, trees and dynamic programming, followed by technical discussion. Details vary by role and year, so treat any description, including this one, as a guide.
Why do the problems here talk about ranking so often?
Ordering results is the core of the product, so ranking, merging and top-k selection are natural practice areas. They also exercise heaps and sorting, which come up in many interviews.
Do front-end candidates get different questions?
Accounts mention a UI-focused round for front-end roles. Prepare for JavaScript, browser behaviour and component design in addition to algorithm problems.
How do I decide between a heap and sorting?
If you need the whole order, sort. If you need only the top k out of a large list, or the data arrives as a stream, a heap of size k is cheaper in time and memory.
Where can I find current openings?
On zomato.com/careers. The Zomato hiring page on this site has sourced news.
Sources
Related guides
More in Company Interview Questions
- 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
- Adobe Interview Questions and Answers for SDE Roles
- Amazon Coding Round Questions with Solutions in Python and Java
- Amazon Interview Questions and Answers for SDE Roles
- AMD Coding Round Questions with Solutions
- AMD Interview Questions and Answers for India Software Roles
- American Express coding round questions with solutions