Skip to content

Commit 39d9e0a

Browse files
authored
Create Incremental Memory Leak.java
1 parent fd43b15 commit 39d9e0a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Medium/Incremental Memory Leak.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int[] memLeak(int memory1, int memory2) {
3+
int currentLeak = 1;
4+
while (Math.max(memory1, memory2) >= currentLeak) {
5+
if (memory1 >= memory2) {
6+
memory1 -= currentLeak++;
7+
} else {
8+
memory2 -= currentLeak++;
9+
}
10+
}
11+
return new int[]{currentLeak, memory1, memory2};
12+
}
13+
}

0 commit comments

Comments
 (0)