There were 3 programming problems, as follows :
1. Given n groups of singers(as array of size n with arr[i] denoting the ith group size) and m microphones available, we had to output the minimum largest group size sharing a single mic.
A group could only be divided into two further groups at a time. (The approach was to use binary search and check for the optimality of the group size.)
Eg: input: arr: [100, 60, 80, 40, 30] , m=9
output:40 (like we can have groups as follows after division: 40,40,20,40,20,40,40,40,30)
Time Complexity: O(nlogn)
Based on Graph: This problem had n nodes numbered from 1 to n and m edges, the goal was to return the connected component with the largest sum of priorities
(an array of priorities was given for each node). A simple dfs based solution possible. Time and space: O(n)
Given a number n(could be negative as well,in the range -10^7 to 10^7), the target was to get the permutation having the smallest magnitude(no leading zeros were allowed).
Ex: for 901 the output should be 109. [I did it by creating an array of its digits and sorting the permutation] Time Complexity: O(nlogn)
I solved all the three problems and took around 45 mins after which I submitted my test.[45 mins still remained :)].
12 students were shortlisted for the technical interview. The interviews were to be held on AMCAT platform.
The first problem flashed on the screen and seeing it I had a subtle smile. A sorted array had been given along with the target number to be found, the statement was
to give the range of indices [l,r] such that all elements in this range are the target. If the target wasn't present, the output was to be an empty array [].
Eg: Input:[5,11,15,80,80,101]
Output: [3,4] (0-based)
I gave 4 approaches for the problem and the interviewer looked very convinced.
Then we came to the next problem, Given an array of only numbers 0-9, we had to maximize the number of buckets in the array given the condition that all the occurrences
of a specific digit had to come in the same bucket.
Eg: Input: [0,0,1,1,2,1,7,8,7,9,9]
Output: 4 ,[0,0],[1,1,2,1],[7,8,7],[9,9]
Another problem was shot next, the statement: Given an n-ary tree, convert it into a binary tree for storage in memory as it wasn't possible to store an n-ary tree.
So, we had to implement encode() and decode() functions for the same.
The Interviewer was very attentive and coordinated wonderfully well, giving instructions and hints whenever needed.
You are given an array of integers (with arr[i] describing the index of the array to which we can jump from the ith index). We were allowed to either move from current
index to the next index or to arr[i] as described. The goal was to minimize the number of jumps(edges traversed) to reach the last index.
Given a binary matrix (0s and 1s only) in which all the rows are sorted. We were to find the maximum number of zeros(in a row) and its row index.
Eg:
Input:
0 0 0 0 1 1 1 1 1 1
0 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 1
0 0 0 1 1 1 1 1 1 1
Output: 8 zeros in 4th row
I first gave a brute force approach of traversing all rows and columns. Time Complexity: O(n*m). He asked to optimize it further.
I gave an O(n+m) approach. Starting from first row and first column, we would go on incrementing col index until we find a 1. When 1 is found,update the answer and move on to the next row. Remember to take care of the edge cases.
I was asked to write a pseudocode and I was happy to do so as well.
Finally the interviewer asked if I had any questions for him to which I asked: What is it like to be a part of Flipkart? What kinds of projects will be assigned to interns? He gave the answer, we had a little chat and the round was over.
This was a Senior Manager taking the interview as opposed to the previous two rounds. He started off by greeting me and asking about the Covid19 scenario in my locality,where I stayed and stuff.
Then he asked me about the semester I was in and the subjects that had till then been taught.
Again he now asked me to tell about myself. I briefly explained my journey in Computer Science domain and where I was headed.
Then he questioned me vividly on my skills and values (typical HR questions). I always connected the questions to an anecdote from my life and went on about how I failed, attempted, gave my best shot, succeeded etc. I had not prepared for even a single question, whatever I said was very natural which made him very impressed and he went on digging deep into those experiences that I told him about.
My JEE story, quizzing as a passion in school, dramatics in college etc. I was so happy to oblige, this was a dream come true HR round for me. He was so humble in the way he spoke and went about asking questions and responded greatly to all my answers. After 21 mins, he said he was done on his part and asked whether I had any questions for him.
I asked the very same question as in previous round and he went on talking about it in great detail, explaining each and every aspect where they are currently facing challenges and scope for research in those domains.
After this,I said I had no further questions and finally we greeted each other and the interview was over. I knew I had done well.
Go rock the stage :) (Because you deserve it!)