Round 1
Questions:
-
Write a class for
RunningSumAverage
. There is an infinite stream of values and you are asked to give the average of the last k values.- Example:
k = 3 ma = RunningSumAverage(4) # window size is 4 ma.add(1) ma.add(3) ma.add(2) ma.add(5) ma.avg() # returns 11/4 = 2 ma.add(8) ma.avg() # returns 17/4 = 4
- Example:
-
Convert a BST to a double linked list (not circular).
-
Mock Questions:
- Move Zeroes - Leetcode Problem Link
- 3Sum - Leetcode Problem Link
Candidate's Approach
- For
RunningSumAverage
, implemented a class that maintains a running sum and calculates the average of the last k values efficiently. - For the BST to double linked list conversion, followed the standard approach of in-order traversal to link nodes in a doubly linked list format.
Interviewer's Feedback
No feedback provided.