leetcode

235. Lowest Common Ancestor of a Binary Search Tree

Solution code

h = height of tree

Time complexity: O(h)

Space complexity: O(1)

Recursive solution code

h = height of tree

Time complexity: O(h)

Space complexity: O(h)