mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
feat: add Swift codes for heap article (#306)
* feat: add Swift codes for heap article * Update heap.md --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
@@ -74,4 +74,12 @@ public enum PrintUtil {
|
||||
print("\(key) -> \(value)")
|
||||
}
|
||||
}
|
||||
|
||||
public static func printHeap(queue: [Int]) {
|
||||
print("堆的数组表示:", terminator: "")
|
||||
print(queue)
|
||||
print("堆的树状表示:")
|
||||
let root = TreeNode.listToTree(list: queue)
|
||||
printTree(root: root)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user