JAVA SOLUTION
Intuition\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Tim
# Intuition\n![images.jfif](https://assets.leetcode.com/users/images/8747bf04-5be3-4512-ae9b-4520f9d7e522_1720419792.1820693.jpeg)\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public List<Integer> busiestServers(int k, int[] arrival, int[] load) {\n        int[] counter = new int[k];\n        // use a tree to track available servers\n        TreeSet<Integer> available = new TreeSet<Integer>();\n        for (int num = 0; num < k; num++) {\n            available.add(num);\n        }\n        // use a PQ to maintain the availability at current arrival time\n        Queue<int[]> busyServers = new PriorityQueue<>((a, b)->(a[0] - b[0]));\n        \n        for (int idx = 0; idx < arrival.length; idx++) {\n            int curTime = arrival[idx];\n            int endTime = curTime + load[idx];\n            while (!busyServers.isEmpty() && busyServers.peek()[0] <= curTime) {\n                int freedServer = busyServers.poll()[1];\n                available.add(freedServer);\n            }\n            if (available.size() == 0) continue; // all busy\n            Integer assignNum = available.ceiling(idx % k);\n            if (assignNum == null) {\n                assignNum = available.first();\n            }\n            counter[assignNum]++;\n            available.remove(assignNum);\n            busyServers.offer(new int[] {endTime, assignNum});\n        }\n        \n        return findMaxesInCounter(counter);\n    }\n    \n    \n    \n    private List<Integer> findMaxesInCounter(int[] counter) {\n        int max = 0;\n        for (int i = 0; i < counter.length; i++) {\n            max = Math.max(max, counter[i]);\n        }\n        List<Integer> result = new ArrayList<>();\n        for (int i = 0; i < counter.length; i++) {\n            if (counter[i] == max) {\n                result.add(i);\n            }\n        }\n        return result;\n    }\n}\n```
['Java']