Approach hintTry it first, then revealHide
Traverse level by level and record the last node of each level, or run a DFS that visits right children first and records the first node seen at each depth.
Traverse level by level and record the last node of each level, or run a DFS that visits right children first and records the first node seen at each depth.