Nutanix | MTS-2 | Feb 2024

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-02-14Added By Anonymous
Source: Link

Company: Nutanix
Role: MTS-2
Interview Stage: Onsite
Location: unknown
Year: 2024

Original Post Content:

Education: B.Tech from Tier 1 institute
Current Experience: 1.6 years
I applied directly on the career portal and got a call for interview within a week.

Round-1
Video interview conducted on Hackerrank CodePair. 2 problems to be solved in 60 minutes.

Problem-1
Given two arrays arr1 and arr2 of n elements, we need to find the maximum value of sum i*(arr2[i] - arr1[i]), where we can rearrange each element of each array as we like.
n <= 10^5, arr1[i], arr2[i] were positive integers less than or equal to 10^9.

Approach: I solved by sorting the first array in ascending order and the second array in descending order, then calculated the required sum. Similarly, sorted the first in descending and the second in ascending and then took the maximum of the two situations.
I missed the fact that we had to calculate the answer modulo 10^9+7. Was able to identify after the interviewer asked to check the constraints properly.
Did one more small mistake. In C++ sort function, I used sort(arr1.begin(), arr1.begin()) instead of sort(arr1.begin(), arr1.end()). That wasted a few minutes to figure out. Was probably out of practice.

Problem-2
It was a little confusing statement but boiled down to something like:
Given an array of n elements, we need to build a score array of n elements.
To build score[i], we need to do the following:
1. Find the maximum of arr[1...i]. Then add it to arr[1].
2. Find the maximum of arr[1...i] of this new arr and then add it to arr[2].
3. Similarly, find the maximum of arr[1...i] of this new arr and then add it to arr[i].
Now we need to do the sum of arr[1...i] of this new modified array. This value becomes score[i].
After each iteration, the array starts fresh, i.e., we calculate score[i+1] on the original arr.

Approach: I wrote a few examples and found out a formula:
score[i] = i*max(arr[1...i]) + i*arr[1] + (i-1) * arr[2] + ... + 1*arr[i]
This can be easily solved using prefix sums.

I managed to solve both problems but just 3 minutes were left for the interview.
It has been more than a day and there has been no reply back from the HR.
Should I keep any hope?

Update: Received a call after 10 days for further rounds. Had 2 more rounds after this.

Round-2
2 DSA problems to be solved in 1 hour.
1. https://leetcode.com/problems/spiral-matrix/description/
It's a well-known problem. Although it took around 15-20 minutes to complete the clean and working code.
2. https://leetcode.com/problems/reverse-nodes-in-k-group/description/
Again a well-known problem, but I messed up this one. Got very much confused in visualizing how to move the linked list pointers; I should have drawn it out on a paper :(
Interviewer tried to hint me for a recursive solution but I was thinking about an iterative one. In the end, I could not complete this problem. Felt very disappointed with myself.

Round-3
1 DSA and 1 LLD problem in 1 hour.
1. It was a standard LeetCode problem https://leetcode.com/problems/number-of-islands/description/
Solved it without any difficulty.
2. Implement a thread-safe LRU cache.
I studied this long back but luckily remembered the idea and was able to code it also. Had good discussions with the interviewer around ensuring thread safety.

Got the feedback that 2 rounds were good, 1 was okay. No further updates on whether I would be called for the HM round. I feel they won't be proceeding forward but am waiting to get final confirmation.

Comments