Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use BFS, traverse the tree level by level and always push the left node first
When you reach the target node, mark a boolean variable true
If you meet another node in the same level after marking the boolean true, return this node.
If you did not meet new nodes in the same level and started traversing a new level, return Null