
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Note that for a node, it's not optimal to consider two nodes with the same value.
Note that the values are small enough for you to iterate over them instead of iterating over the parent nodes.