[Java] Elegant and Concise || Using PriorityQueue and TreeSet
\nclass Solution {\n    public List<Integer> busiestServers(int k, int[] arrival, int[] load) {\n        \n        TreeSet<Integer> avalServers = new TreeSet<>(
```\nclass Solution {\n    public List<Integer> busiestServers(int k, int[] arrival, int[] load) {\n        \n        TreeSet<Integer> avalServers = new TreeSet<>();\n        for(int i=0; i<k; i++){\n            avalServers.add(i);\n        }\n        \n        PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]); // [Ending Times, Server]\n        int[] count = new int[k]; // To count the number of requests handled by each server\n        for(int i=0; i<arrival.length; i++){\n            // Free the servers who have serviced the request\n            while(!pq.isEmpty() && pq.peek()[0] <= arrival[i]){\n                avalServers.add(pq.poll()[1]);\n            }\n            \n            // Find the available server  for the current request \n            if(avalServers.size() == 0) continue; // Request Dropped\n            \n            int serverReq = i%k;\n            Integer nextServ = avalServers.ceiling(serverReq);\n            if(nextServ != null){\n                avalServers.remove(nextServ);\n            }else{\n                // Find the smallest numbered server\n                nextServ = avalServers.first();\n                avalServers.remove(nextServ);\n            }\n            \n            pq.offer(new int[]{arrival[i] + load[i], nextServ});\n            count[nextServ]++; \n        }\n        \n        int max = -1;\n        List<Integer> ans = null;\n        for(int i=0; i<k; i++){\n            if(count[i] > max){\n                ans = new ArrayList<>();\n                max = count[i];\n                ans.add(i);\n            }else if(count[i] == max){\n                ans.add(i);\n            }\n        }\n        \n        return ans;\n    }\n}\n```
[]