How to optimise the inner while loop?
Hello,\n\nMy following solution gave TLE and I got stuck at how to optimise this further.\n\nHow can I approach such problem?\n\nclass Solution {\n    public Li
Hello,\n\nMy following solution gave TLE and I got stuck at how to optimise this further.\n\nHow can I approach such problem?\n```\nclass Solution {\n    public List<Integer> busiestServers(int k, int[] arrival, int[] load) {\n        long[] busy = new long[k];\n        int[] nums = new int[k];\n        int max = 0;\n        for(int i=0;i<arrival.length; i++){\n            int server = i % k;\n            while(busy[server]>arrival[i]) {\n                server = (server+1) % k;\n                if(server == i%k) break;\n            }\n            System.out.println(busy[server]+" "+arrival[i]+" "+i+" server="+server);\n            if(busy[server]>arrival[i]) continue;\n            \n            busy[server] = arrival[i]+load[i];\n            nums[server]++;\n            max = Math.max(max, nums[server]);\n        }\n        \n        List<Integer> ans = new ArrayList<>();\n        for(int i=0;i<k;i++){\n            System.out.println(nums[i]);\n            if(nums[i]==max) ans.add(i);\n        }\n        return ans;\n    }\n}\n```
[]