All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g1801_1900.s1860_incremental_memory_leak.Solution Maven / Gradle / Ivy

There is a newer version: 1.24
Show newest version
package g1801_1900.s1860_incremental_memory_leak;

// #Medium #Simulation #2022_05_08_Time_5_ms_(78.57%)_Space_41.9_MB_(34.69%)

public class Solution {
    public int[] memLeak(int memory1, int memory2) {
        int time = 1;
        while (memory1 >= time || memory2 >= time) {
            if (memory1 >= memory2) {
                memory1 -= time;
            } else {
                memory2 -= time;
            }
            time++;
        }
        return new int[] {time, memory1, memory2};
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy