
Dunzo


Dunzo SDE-2 Interview Questions and Answers
Q1. Container with Most Water Problem Statement
Given a sequence of 'N' space-separated non-negative integers A[1], A[2], ..., A[i], ..., A[n], where each number in the sequence represents the height of a line draw...read more
Find two lines to form a container with maximum water area on a Cartesian plane.
Iterate through the array from both ends to find the maximum area.
Calculate the area using the formula: (min(height[left], height[right]) * (right - left)).
Update the pointers based on the height of the lines to maximize the area.
Q2. Number of Subsequences with Even and Odd Sum
Your task is to determine the number of subsequences with odd sums and the number of subsequences with even sums from a given array of positive integers. As resultin...read more
Count the number of subsequences with odd and even sums in a given array of positive integers modulo 10^9 + 7.
Use dynamic programming to keep track of the count of subsequences with odd and even sums.
Consider the parity of each element in the array to determine the count of subsequences with odd and even sums.
Apply modulo 10^9 + 7 to handle large resulting numbers.
Example: For input [1, 2, 3], there are 3 subsequences with odd sums and 4 subsequences with even sums.
Q3. Minimum Cost to Reduce Array Problem Statement
You are given an array ARR
containing N
positive integers. Your task is to reduce the size of this array to 1 by repetitively merging adjacent elements. Each time ...read more
Find the minimum cost to reduce an array to a single element by merging adjacent elements with their sum.
Iteratively merge adjacent elements to minimize total cost
Choose pairs to merge strategically to reduce cost
Calculate sum of adjacent elements and update array size
Q4. Maximum Size Rectangle Binary Sub-Matrix with All 1s
Given a binary-valued matrix of size N x M
, your task is to determine the largest area of a submatrix that contains only 1's.
Input:
The first line contains ...read more
Find the largest area of a submatrix containing only 1's in a binary matrix.
Iterate over each cell in the matrix and calculate the maximum area of submatrix with all 1's ending at that cell.
Use dynamic programming to keep track of the maximum area ending at each cell.
Update the maximum area as you iterate through the matrix.
Return the overall maximum area found in the matrix.
Q5. Anagram Substring Search
Given two strings 'STR' and 'PTR', identify all starting indices of 'PTR' anagram substrings in 'STR'. Two strings are anagrams if one can be rearranged to form the other.
Input:
First ...read more
Identify starting indices of anagram substrings of 'PTR' in 'STR'.
Use a sliding window approach to check for anagrams of 'PTR' in 'STR'.
Create a frequency map of characters in 'PTR' and 'STR' to compare.
Slide the window along 'STR' and check if the frequency maps match.
Return the starting indices where anagrams are found.
Q6. Next Greater Element Problem Statement
You are given an array arr
of length N
. For each element in the array, find the next greater element (NGE) that appears to the right. If there is no such greater element, ...read more
The task is to find the next greater element for each element in an array to its right, if no greater element exists return -1.
Use a stack to keep track of elements for which the next greater element is not found yet.
Iterate through the array from right to left, popping elements from the stack until a greater element is found.
Store the next greater element for each element in a separate array.

Top SDE-2 Interview Questions from Similar Companies







Reviews
Interviews
Salaries
Users/Month

