Round 2: PS-DS Round (1 hr)
This was a problem solving and data structures related round.
Interviewer asked me following questions with working code.
- At any point of time, find the average of max k numbers from an incoming stream of infinite numbers. I solved it using min-heap of k size and maintaining a sum variable to find the average. For every insertion to min-heap add the element to sum and for every deletion from min-heap, subtract the element from sum. To get the average return sum/no. of elements.
- Copy the contents of a given stack to another stack in same order without using extra space.
- Rain water trapping problem. https://www.w3wiki.org/trapping-rain-water/
I solved all of the above problems and my interviewer was satisfied.
Contact Us