type
status
date
slug
summary
tags
category
icon
password

2471. Minimum Number of Operations to Sort a Binary Tree by Level

 
2nd approach deals with with cycle lengths. This approach is more Math. That one is related to the permutation group on [0,1,..qz-1]. That one is based on the fact that each permutation is a series of cyclic transformations.
A cyclic transformation can be denoted by (i0​,i1​,...,ik​) which is fn fact i0​→i1​,i1​→i2​,⋯,ik−1​→ik​,ik​→i0​. A cyclic transformation of length k+1 can be performed by k 2-cycles(i.e. swaps).
The length's counting is using DFS.
notion image
For better understanding the permuation, let's consider the nodes on 2th level.
=>
The permutations are listed by the following
They can be represented by a cyclic transform (0,2,3) which has length 3. This cyclic transform of length 3 can be proceeded by 2 swaps (2,3) then (0, 2) (order cannot be reversed, 2=|cycle|-1=3-1)
 
第一个post 音乐播放器测试Flutter 基础 记录
Loading...
ran2323
ran2323
我们再来一次, 这一次, 好好来!
Latest posts
Git 指令 小总结
2025-1-9
Leetcode记录「2」
2024-12-27
Flutter 基础 记录
2024-12-25
Flutter tutorial 记录
2024-12-25
Privicy policy for GitHub To Text (Chrome Extension)
2024-12-22
一些 Kubernetes 笔记
2024-12-21
Announcement
 
 
 
 
暂时没有新的内容