Binary Search + Priority Queue (Well Explained) || NLOGN || JAVA
\nclass Solution {\n  class node {\n    int expire;\n    int idx;\n\n    node(int e, int i) {\n      expire = e;\n      idx = i;\n    }\n  }\n\n  public List<In
```\nclass Solution {\n  class node {\n    int expire;\n    int idx;\n\n    node(int e, int i) {\n      expire = e;\n      idx = i;\n    }\n  }\n\n  public List<Integer> busiestServers(int k, int[] arrival, int[] load) {\n\n    //Free Server List.\n    TreeSet<Integer> ts = new TreeSet<>();\n    for (int i = 0; i < k; i++)\n      ts.add(i);\n\n\n    int max_count = 0;\n\n    HashMap<Integer, Integer> count = new HashMap<>();\n\n    //Maintains the count list of busy servers by computation expiration time\n    PriorityQueue<node> pq = new PriorityQueue<>((node a, node b) -> a.expire - b.expire);\n\n    for (int i = 0; i < arrival.length; i++) {\n\n      //Add to free server list if the computation is finished\n      while (!pq.isEmpty() && pq.peek().expire <= arrival[i]) {\n        node p = pq.poll();\n        ts.add(p.idx);\n      }\n\n      //No Free Server\n      if (ts.size() == 0)\n        continue;\n\n\n      //Find next server that is equal or just greater.\n      Integer ceil = ts.ceiling(i % k);\n\n\n      //If not found get the first available server\n      if (ceil == null)\n        ceil = ts.first();\n\n\n      //Remove from free server list\n      ts.remove(ceil);\n\n      count.put(ceil, count.getOrDefault(ceil, 0) + 1);\n\n      //Add to busy server list.\n      pq.add(new node(arrival[i] + load[i], ceil));\n\t  \n\t  //update maxcount\n\t  max_count=Math.max(max_count,count.get(ceil));\n\n\n    }\n\n\n    //Get the most used server.\n    List<Integer> ans= new ArrayList<>();\n\n    for (Map.Entry<Integer,Integer> e:count.entrySet())\n    {\n      if (e.getValue()==max_count)\n      {\n        ans.add(e.getKey());\n      }\n    }\n\n    return ans;\n\n\n  }\n}\n\n```
[]