Sponsored
Use these hints if you're stuck. Try solving on your own first.
How can we use the small constraints to help us solve the problem?
How can we traverse the ancestors and descendants of a node?
Solve with full IDE support and test cases