Description:
Solution:
Start from root.
If both p, q is less than root, we are gonna see the left portion of root.
elif both p, q is more than root, we are gonna see the right portion of root.
Other cases have a root as a LCA node in the Tree.
Time Complextiy: O(logn)
Space Complexity: O(1)
'LeetCode ๐๏ธ > Tree' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
212. Word Search II (0) | 2023.06.12 |
---|---|
211. Design Add and Search Words Data Structure (0) | 2023.06.11 |
230. Kth Smallest Element in a BST (0) | 2023.06.05 |
297. Serialize and Deserialize Binary Tree (0) | 2023.06.04 |
98. Validate Binary Search Tree (0) | 2023.06.03 |