import Foundation class HeapSortSolution { func sort(_ n: [Int]) -> [Int] { var s = n //1.初始化堆 var i = n.count/2 - 1 while i >= 0 { ...
import Foundation extension MyTreeNodeSolution { //递归 func postOrderTraversal(_ root: TreeNode?,_ n: inout [Int]) { if root == nil { return } ...
import Foundation class ShellSortSolution { func sort(_ n: [Int]) -> [Int] { var s = n var gap = n.count/2 while gap > 0 { ...
题目描述:有个游戏是这样的:首先,让小朋友们围成一个大圈。然后,他随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m-1的那个小朋友要出列并且不再回到圈中,从他的下一个小朋友开始,继续0…m-1报数….这样下去….直到剩下最后一个小朋友,求最后一个小朋友的编号import Foundation class For45Solution { func deleteNum(_ n:...