-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ function canJump(nums: number[]): boolean { | |
} | ||
return zeroIndex == -1; | ||
}; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Day 42 Binary Heap | ||
|
||
Extend and implement a bianry heap class below. | ||
|
||
```ts | ||
abstract class BinaryHeap{ | ||
// type: true is max heap, false is min heap | ||
// default min heap | ||
constructor(heap:number[], type?: bool = false); | ||
|
||
private heap: number[]; // store value inside heap | ||
private type: bool; | ||
private heapify(): void; // sort heap | ||
|
||
public IsEmpty(): bool; // if heap is empty, return true | ||
public root(): number; // return value of root | ||
public pop(): number; // pop root value and remove from heap | ||
public push(value: number); // insert a value into heap and call heapify to sort | ||
} | ||
``` | ||
|
||
Here is some introduction | ||
|
||
http://alrightchiu.github.io/SecondRound/priority-queuebinary-heap.html | ||
|
||
https://medium.com/@Kadai/%E8%B3%87%E6%96%99%E7%B5%90%E6%A7%8B%E5%A4%A7%E4%BE%BF%E7%95%B6-binary-heap-ec47ca7aebac |
This file contains 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