Minimum Number of Operations to Sort a Binary Tree by Level - Leetcode 2471 - Java

preview_player
Показать описание
Problem Description

You are given the root of a binary tree with unique values.

In one operation, you can choose any two nodes at the same level and swap their values.

Return the minimum number of operations needed to make the values at each level sorted in astrictly increasing order.

The level of a node is the number of edges along the path between it and the root node.

Рекомендации по теме