Skip to content

Latest commit

 

History

History
26 lines (14 loc) · 700 Bytes

2020_08_13.md

File metadata and controls

26 lines (14 loc) · 700 Bytes

Aug 13, 2020

Topic: Sample Challenge: Largest Smaller BST Key

Agenda

  • Discuss sample challenge
  • AOB

Challenge

Largest Smaller BST Key

Given a root of a Binary Search Tree (BST) and a number num, implement an efficient function findLargestSmallerKey that finds the largest key in the tree that is smaller than num. If such a number doesn’t exist, return -1. Assume that all keys in the tree are nonnegative.

Analyze the time and space complexities of your solution.

For example:

For num = 17 and the binary search tree below:

keys = [ 20, 9, 25, 5, 12, 11, 14, 18, 19]

Your function would return:

14 since it’s the largest key in the tree that is still smaller than 17.