Back-to-back coding interviews, 45 mins each. Finished the rounds on Tuesday and heard back today that I didn't pass.
Round 1
- https://leetcode.com/problems/nested-list-weight-sum/description/. Minor variant: Instead of dedicated data structure in the leetcode problem, it's just integer and list.
- https://leetcode.com/problems/merge-k-sorted-lists/description/. Minor variant: k = 3, instead of linked lists it were 3 arrays, and duplicates should be avoided in the final result. I stucked a tiny bit (somehow I tried to use 3 pointers) but finally landed on the heap solution with minimal hints. The interviewer asked in the end if I can do better, and I didn't manage to think of another solution, yet he said it's fine. (According to discussion in the comments, using the idea of merge sort can give the same time complexity and better space complexity than the heap method, which probabaly was what the interviewer was looking for)
Round 2
- https://leetcode.com/problems/kth-largest-element-in-an-array/editorial/. I gave the heap solution. The interviewer asked if there are any other solutions, and I talked about quickselect and binary search.
- Check if there is a subarrary whose sum equals to a target. I gave prefix sum solution.
After some reflection I realized that I didn't ask the clarifying question for round 2 question 2 in terms of whether the array only has positive numbers or not. If so we should go for sliding window for O(n) time and O(1) space which is better than prefix sum's O(n) time and O(n) space. This definitely could improved, but meanwhile I'm not sure how much it affected my rating. Is this a red flag?
Comments (10)


