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

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 .

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.

If anyone has a solution or a detailed approach to solve these problems efficiently, please share it. I would appreciate any help or suggestions. Thank you in advance!

Comments (2)