Amazon SDE-II | Phone screen round experience.
Company: Amazon
Role: SDE II
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
DSA Round. No leadership question asked.
1. My introduction.
2. Calculate sum of each subarray of size K for an array.
Started with brute force and explained the improvement parts to reach the optimal solution using Sliding Window.
Explained time and space complexity.
Re-iterated and dry-ran the edge cases to make sure the solution works perfectly.
I wasn't asked to compile the code.
3. Follow-up question -> Return max of each window instead of the sum.
I provided 3 approaches
a. If all the elements are distinct, sliding window can be used with values of each window being kept in a set and a maxHeap can be used to determine the max value on each step of the sliding window. If at any step the max is not in the set -> heapPop() and then check again if the max of heap is in the set.
b. If the elements are not distinct, we can use a map instead of a set so that the heapPop() is done only when the count of the maxElement of heap is 0.
c. We can use a segment tree to store the array and return max of each segment.
I explained the time complexity and space complexity in each of the cases.
At the end I asked one query to the interviewer about the range of work that I'll be covering.
Expected Verdict according to me - Inclined