We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b0ae1eb commit 75c0cd6Copy full SHA for 75c0cd6
src/easy/last_stone_weight.rs
@@ -13,6 +13,22 @@ fn last_stone_weight(stones: Vec<i32>) -> i32 {
13
*max_heap.peek().unwrap_or(&0)
14
}
15
16
+/*
17
+ Algorithm - Heap
18
+
19
+ Time O(NlogN)
20
+ Space O(N)
21
22
+ Description:
23
+ 1. Create a max heap
24
+ 2. Pop 2 items from the heap
25
+ 3. If they are not equal, push the difference to the heap
26
+ 4. Repeat 2-3 until the heap has 1 or 0 items
27
+ 5. Return the top item of the heap
28
29
30
+*/
31
32
#[cfg(test)]
33
mod tests {
34
use super::*;
0 commit comments