Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 915 Bytes

File metadata and controls

34 lines (27 loc) · 915 Bytes
  • You are given pointer to the root of the binary search tree and two values v1 and v2. You need to return the lowest common ancestor (LCA) of v1 and v2 in the binary search tree.

  • Instance format:

    • The first line contains an integer, n, the number of nodes in the tree.
    • The second line contains n space-separated integers representing node, data values.
    • The third line contains two space-separated integers, v1 and v2.
  • Input:

        6
        4 2 3 1 7 6
        1 7
  • Output:
        [reference to node 4]

Running

  • Running an instance:
    python main.py "path_instance"
  • Example: running an instance "input1":
    python main.py instances/input1