Skip to content

Latest commit

 

History

History
13 lines (10 loc) · 380 Bytes

File metadata and controls

13 lines (10 loc) · 380 Bytes

Problem 7: Familial Nexus (BST)

Problem Statement

Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.

Input Format

  • The root of a BST.
  • Two target nodes p and q.

Example

Input: root = [6, 2, 8, 0, 4, 7, 9, null, null, 3, 5], p = 2, q = 8
Output: 6
Explanation: The LCA of 2 and 8 is 6.