C++ | Easy Commented Code
\nclass Solution {\npublic:\n    vector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {\n        //stores all the servers that are busy.\n
```\nclass Solution {\npublic:\n    vector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {\n        //stores all the servers that are busy.\n        //pair.first = time at which it will get free\n        //pair.second = id of the server\n        set<pair<int,int>>busyServer;\n        \n        //tracks the number of requests served by k servers\n        vector<int>frequency(k,0);\n        \n        //tracks the available servers.\n        set<int>availableServer;\n        for(int i=0;i<k;i++){\n            availableServer.insert(i);\n        }\n        \n        //simulate the process\n        for(int i=0;i<arrival.size();i++){\n            while(!busyServer.empty()){              \n                //it pointing to first pair of busyServer\n                auto it = busyServer.begin();\n                \n                if(it->first<=arrival[i]){\n                    //unload the first server because at time\n                    //arrival[i], that server will become free to use again.\n                    //Add the id of that server to available server.\n                    availableServer.insert(it->second);\n                    busyServer.erase(it);\n                }else{\n                    //if the first element has greater time than\n                    //arrival[i] then all the elements of set will have \n                    //greater than arrival[i], as set is sorted in increasing order\n                    break;\n                }\n            }   \n            \n            //if there are no available servers then drop the current request\n            if(availableServer.size()==0){\n                continue;\n            }\n            \n            //find the i%k server from available server. If that points to end\n            //then take the first available server from the list, assuming the cyclic \n            //nature\n            auto it = availableServer.lower_bound(i%k);\n            if(it==availableServer.end()){\n                it = availableServer.begin();\n            }\n            \n            //remove the it from available server and insert into busy server\n            //note: insert ending time = arrival[i]+load[i]\n            int id = *it;\n            frequency[id]++;\n            availableServer.erase(it);\n            busyServer.insert({arrival[i]+load[i],id});\n        }\n        \n        //finding the busiest server\n        vector<int>result;\n        int maxx = -1;\n        for(auto it:frequency){\n            maxx = max(maxx,it);\n        }\n        \n        for(int i=0;i<k;i++){\n            if(frequency[i]==maxx){\n                result.push_back(i);\n            }\n        }\n        \n        return result;\n    }\n};\n```
['C']