Uber Phone Screen

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-04-18Added By Anonymous
Source: Link

Company: Uber
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Given a binary search tree (BST) find the kth largest element.

Example:

           10
/ \
4 20
/ / \
2 15 40

k = 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:

             10
/ \
4 20
/ / \
2 15 40

k = [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

Comments