Interviewer 1:
Q1: Find k largest element from an array.
Sorted array and get kth element. Explain the complexity.
Q2: Find minimum distanced node value from target and a given BST.
Traverse BST, store and update the minimum distance between the node value and target. Explain the complexity.
Interviewer 2:
list1: 1, 4, 9, 13
list2: 2, 12, 20, 25
list3: 4, 9, 25
There could be n list containing m int each.
Find u, v such that at least one element from each of the list belongs to u, v inclusive and v-u is minimum.
Gave a solution like this, put all the value into set. For each possible pair u, v from the set check if constraint is satisfied and store the minimum v-u. Then he said u, v may be some arbritrary value. Come up with a solution of iterating u from the set and do a binary search to find v. But it takes some time to get to the solution. Then he asked to write up the first solution. Wrote code without any bugs in the first pass. Did complexity analysis wrong. Instead of O(unq_ele^2 * m * n) said O(unq_ele * m * n). Didn't get time to implement the binary search idea and he said it will work and move to the last question session. Got rejection in the email.
Didn't get any feedback. Probably rejected because of not able to complete the code for optimized version and getting the complexity wrong in the 2nd round. Any thought? Also does anyone know same question as interviewer 2 from leetcode? Thanks!