This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct MinHeap { | |
| var items: [Int] = [] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct MinHeap { | |
| var items: [Int] = [] | |
| //Get Index | |
| private func getLeftChildIndex(_ parentIndex: Int) -> Int { | |
| return 2 * parentIndex + 1 | |
| } | |
| private func getRightChildIndex(_ parentIndex: Int) -> Int { | |
| return 2 * parentIndex + 2 | |
| } |
NewerOlder