Problem - B1 - Codeforces Can anyone help me about understanding this solution? I found a greedy soln where each node swaps its value with parent , and root swaps with one of its children. However what is the intuition behind this and pls explain me the proof behind it?. Is there any dp solution to this?