Eternal (Zomato) | Fresh Graduate OA 2026 | On-Campus Recruitment

zomato logo
zomato
· Fresh Graduate
August 7, 2025 · 63 reads

Summary

I experienced an Online Assessment for a Fresh Graduate role at Zomato (Eternal program), which consisted of 3 DSA problems and 18 MCQs on CS fundamentals and ML. I have provided the details of the DSA problems encountered.

Full Experience

OA Pattern : 3 DSA 65 minutes, 18 MCQs 20 minutes MCQs were based on CS fundaments and ML


Problem 1: Minimum Swaps to Sort Non-Zeros (100 points)

You are given an array of integers, where some elements are zeros and others are non-zero integers. Your task is to find the minimum number of swaps required to sort the non-zero elements in ascending order, while keeping all zeros at the end of the array.

Rules:

  • You can only swap a non-zero element with a zero.

Problem 2: Minimize Longest Continuous Sequence After Flipping (60 points)

You are given a string consisting only of the characters 'a' and 'b'. You can flip characters, meaning you can swap 'a' to 'b' and vice versa, at most k times.

Your task is to minimize the length of the longest continuous sequence of the same character (either 'a' or 'b') in the string, after performing at most k flips.

Problem 3: Max Score of Substrings (50 points)

You are given a string s and a number k. You need to calculate the maximum score of any substring of length k in the string. The score of a substring is calculated as follows:

For each character in the substring:

  • Its "character value" raised to the power of its frequency in the substring.

The character values are as follows:

  • 'a' = 1, 'b' = 2, ..., 'z' = 26.

Return the maximum score among all substrings of length k. Since the result can be large, return it modulo $10^9 + 7$.

Example 1:

Input: s = "abaab", k = 2
Output: 3
Explanation: The substrings of length 2 are: 
  "ab" → score = 1^1 + 2^1 = 3
  "ba" → score = 2^1 + 1^1 = 3
  "aa" → score = 1^2 = 1
  "ab" → score = 1^1 + 2^1 = 3
The maximum score is 3.

Interview Questions (3)

1.

Minimum Swaps to Sort Non-Zeros

Data Structures & Algorithms

You are given an array of integers, where some elements are zeros and others are non-zero integers. Your task is to find the minimum number of swaps required to sort the non-zero elements in ascending order, while keeping all zeros at the end of the array.

Rules:

  • You can only swap a non-zero element with a zero.
2.

Minimize Longest Continuous Sequence After Flipping

Data Structures & Algorithms

You are given a string consisting only of the characters 'a' and 'b'. You can flip characters, meaning you can swap 'a' to 'b' and vice versa, at most k times.

Your task is to minimize the length of the longest continuous sequence of the same character (either 'a' or 'b') in the string, after performing at most k flips.

3.

Max Score of Substrings

Data Structures & Algorithms

You are given a string s and a number k. You need to calculate the maximum score of any substring of length k in the string. The score of a substring is calculated as follows:

For each character in the substring:

  • Its "character value" raised to the power of its frequency in the substring.

The character values are as follows:

  • 'a' = 1, 'b' = 2, ..., 'z' = 26.

Return the maximum score among all substrings of length k. Since the result can be large, return it modulo $10^9 + 7$.

Example 1:

Input: s = "abaab", k = 2
Output: 3
Explanation: The substrings of length 2 are: 
  "ab" → score = 1^1 + 2^1 = 3
  "ba" → score = 2^1 + 1^1 = 3
  "aa" → score = 1^2 = 1
  "ab" → score = 1^1 + 2^1 = 3
The maximum score is 3.
Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!