GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • rulcode
  • Sign In

This view

  • Original page
  • New address

GeezerVison is showing rulcode.com — Lowest Common Ancestor Visualizer & Solution | Rulcode

Fetching algorithms...

    Lowest Common Ancestor Visualizer & Solution | Rulcode
    Loading problem details...

    18. Lowest Common Ancestor

    Medium
    Topics
    Hint

    Understand Before Coding

    Visualize This Problem
    Open Visualizer
    Draw Your Approach
    Draw

    Example 1:

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

    Example 2:

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

    Example 3:

    Input: root = [2,1], p = 2, q = 1
    Output: 2
    Explanation: The LCA of nodes 2 and 1 is 2.

    Constraints:

    • •
    • •
    • •
    • •
    • •

    Time Complexity

    O(n)

    Space Complexity

    O(h)

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.