Skip to content

Zomato Coding Questions

This comprehensive collection contains Zomato coding questions from previous year placement papers with detailed solutions. Practice these problems to master Zomato’s coding section covering DSA, system design, and behavioral questions.

Parameter Details
Total Problems 2-3 DSA problems
Time Allocated 90-120 minutes
Difficulty Medium to Hard
Languages Allowed Java, C++, Python, Go
Platform HackerRank or Zomato’s internal tool
Additional Debugging questions
Q1: Maximum Sum Subarray (Kadane’s Algorithm)

Given an array of integers, find the maximum sum subarray.

Example: Input: [-2, 1, -3, 4, -1, 2, 1, -5, 4], Output: 6 (subarray [4, -1, 2, 1])

Solution:

def max_subarray_sum(arr):
max_sum = float('-inf')
current_sum = 0
for num in arr:
current_sum += num
if current_sum > max_sum:
max_sum = current_sum
if current_sum < 0:
current_sum = 0
return max_sum

Explanation: Use Kadane’s algorithm - maintain current sum and reset to 0 if negative. Time: O(n), Space: O(1)

Answer: 6

Q2: Shortest Path in Graph (Dijkstra’s Algorithm)

Find shortest path between two nodes in a weighted graph using Dijkstra’s algorithm.

Example: Graph with nodes A, B, C, D and edges (A→B: 1), (A→C: 4), (B→C: 2), (C→D: 1), (B→D: 5). Shortest path from A to D: A→B→C→D (cost: 4)

Solution:

import heapq
def dijkstra(graph, src, dest):
n = len(graph)
dist = [float('inf')] * n
dist[src] = 0
pq = [(0, src)]
while pq:
d, u = heapq.heappop(pq)
if u == dest:
return d
if d > dist[u]:
continue
for v, w in graph[u]:
if dist[u] + w < dist[v]:
dist[v] = dist[u] + w
heapq.heappush(pq, (dist[v], v))
return dist[dest]

Explanation: Use priority queue to always process node with minimum distance. Time: O((V+E)logV), Space: O(V)

Answer: 4

Q3: Coin Change Problem

Given coins and amount, find minimum coins needed using dynamic programming.

Example: coins = [1, 2, 5], amount = 11. Output: 3 (5 + 5 + 1)

Solution:

def coinChange(coins, amount):
dp = [amount + 1] * (amount + 1)
dp[0] = 0
for i in range(1, amount + 1):
for coin in coins:
if coin <= i:
dp[i] = min(dp[i], dp[i - coin] + 1)
return -1 if dp[amount] > amount else dp[amount]

Explanation: DP approach - for each amount, try all coins and take minimum. Time: O(amount × coins), Space: O(amount)

Answer: 3

Q4: Binary Tree Level Order Traversal

Given a binary tree, return level order traversal.

Example: Tree [3,9,20,null,null,15,7] → [[3], [9,20], [15,7]]

Solution:

def levelOrder(root):
if not root:
return []
result = []
queue = [root]
while queue:
level = []
size = len(queue)
for _ in range(size):
node = queue.pop(0)
level.append(node.val)
if node.left:
queue.append(node.left)
if node.right:
queue.append(node.right)
result.append(level)
return result

Explanation: Use BFS with queue, process each level. Time: O(n), Space: O(n)

Answer: [[3], [9,20], [15,7]]

Q5: Two Sum Problem

Find two numbers that add up to target.

Example: nums = [2,7,11,15], target = 9 → [0,1]

Solution:

def twoSum(nums, target):
hash_map = {}
for i, num in enumerate(nums):
complement = target - num
if complement in hash_map:
return [hash_map[complement], i]
hash_map[num] = i
return []

Explanation: Use hash map to store seen numbers. Time: O(n), Space: O(n)

Answer: [0, 1]

Q6: Longest Palindromic Substring

Find longest palindromic substring in a string.

Example: “babad” → “bab” or “aba”

Solution:

def longestPalindrome(s):
def expand(l, r):
while l >= 0 and r < len(s) and s[l] == s[r]:
l -= 1
r += 1
return s[l+1:r]
result = ""
for i in range(len(s)):
odd = expand(i, i)
even = expand(i, i+1)
result = max(result, odd, even, key=len)
return result

Explanation: Expand around center for odd/even length palindromes. Time: O(n²), Space: O(1)

Answer: “bab” or “aba”

Q7: Merge Intervals

Merge overlapping intervals.

Example: [[1,3],[2,6],[8,10],[15,18]] → [[1,6],[8,10],[15,18]]

Solution:

def merge(intervals):
intervals.sort(key=lambda x: x[0])
merged = []
for interval in intervals:
if not merged or merged[-1][1] < interval[0]:
merged.append(interval)
else:
merged[-1][1] = max(merged[-1][1], interval[1])
return merged

Explanation: Sort by start, merge if overlapping. Time: O(n log n), Space: O(n)

Answer: [[1,6],[8,10],[15,18]]

Q8: Valid Parentheses

Check if parentheses string is valid.

Example: “()[]” → true, “([)]” → false

Solution:

def isValid(s):
stack = []
mapping = {')': '(', '}': '{', ']': '['}
for char in s:
if char in mapping:
if not stack or stack.pop() != mapping[char]:
return False
else:
stack.append(char)
return not stack

Explanation: Use stack to match opening/closing brackets. Time: O(n), Space: O(n)

Answer: true for “()[]”, false for “([)]”

Practice More Zomato Interview Questions →

Swiggy · Flipkart · Paytm · Phonepe · Meesho · Blinkit

Ready to practice Zomato coding questions? Focus on DSA fundamentals, system design, and Zomato values. Practice with Zomato placement papers and solve problems in Java, C++, Python, or Go.

Pro Tip: Practice medium to hard difficulty problems on LeetCode and HackerRank. Focus on optimal solutions and clear explanations. Use Zomato placement papers for realistic practice. Watch YouTube tutorials (Striver, Take U Forward) for detailed explanations of complex problems.