Uber Phone Screen
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-04-18Added By Anonymous
Source: Link
Company: Uber
Interview Stage: Phone Screen
Original Post Content:
Given a binary search tree (BST) find the kth largest element.
Example:
1 10
2 / \
3 4 20
4 / / \
5 2 15 40k = 2
output: 20
Method signature:
public int kthLargest(TreeNode root, int k) {}
Follow up:
Given a list of kth values find return the number cooresponding
public int kthLargest(TreeNode root, List<Integer> k) {}
Example:
1 10
2 / \
3 4 20
4 / / \
5 2 15 40k = [2, 1, 30, 6]
output: [20, 40, null, 2]
Talked through solution, got buy in from interviewer, and solved problem on time.
Got rejected. Life is funny that way lol