AlgoFrames

Spot the bug: forgotten lower bound

Standard · Find the bug · about 8 min

This check accepts some trees that are not BSTs. Click the line with the bug, then fix it.

Example 1

Input:

[[5,1,4,null,null,3,6]]

Output:

false

The buggy code returns true here.

Constraints

  • 0 ≤ number of nodes ≤ 1,000
  • -1,000 ≤ key ≤ 1,000
  • The tree is given in level order; null marks a missing child

Learn the idea first: Validating a BST and the in-order property, a visual lesson.

More Validating a BST and the in-order property problems