Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try to solve recursively for each level independently.
While performing a depth-first search, pass the left and right nodes (which should be paired) to the next level. If the current level is odd, then reverse their values, or else recursively move to the next level.