contains category wise problems(data structures, competitive) of popular platforms.
View the Project on GitHub mayankdutta/category-wise-problems
236. Lowest Common Ancestor of a Binary Tree
p
, q
or nullptr
, we will immediately return root.
p
, we need not to further in that subtree, only search in another one.q
, reason same as above.nullptr
, no TreeNode
exists for which we were findingleft
and right
both not nullptr.
p
must be in one subtree and q
must be in separate subtreeleft
or right
were nullptr.