力扣1860

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

 

posted @ 2021-05-17 14:39  新晋小白白  阅读(61)  评论(0)    收藏  举报