Skip to content

Commit e681626

Browse files
authored
Added solution for 1860
1 parent 081845c commit e681626

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

01860. Incremental Memory Leak.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
impl Solution {
2+
// Run a loop where in each second memory gets reduced from each memory stick. If both memory sticks don't have enough memory left, return the result with the number of second and the memory left on both the sticks
3+
pub fn mem_leak(mut memory1: i32, mut memory2: i32) -> Vec<i32> {
4+
let mut second = 1;
5+
while (second <= memory1) || (second <= memory2) {
6+
if memory1 >= memory2 {
7+
memory1 -= second;
8+
} else {
9+
memory2 -= second;
10+
}
11+
second += 1;
12+
}
13+
return vec![second, memory1, memory2];
14+
}
15+
}

0 commit comments

Comments
 (0)