C++ sol || brute force to optimized
Code : Brute Force\n\nclass Solution {\npublic:\n    vector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {\n        \n        vector<int>
# Code : Brute Force\n```\nclass Solution {\npublic:\n    vector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {\n        \n        vector<int> res;\n        if(k >= arrival.size()){\n            for(int i = 0; i < arrival.size(); i++)\n                res.push_back(i);\n            return res;\n        }\n\n        // track the finished time of the each sever\n        vector<int>finished_time(k,0); // initial 0\n        vector<int>count(k,1); // no. of time assign the req\n        int mx = 1; // each server have intial 1 req , so mx_req = 1\n\n        for(int i = 0; i < k; i++)\n        {\n            finished_time[i] = arrival[i]+load[i];\n        }\n\n        for(int i = k; i < arrival.size(); i++)\n        {\n            int ind = i % k;\n            int flag = 0; // to find any free server at that time\n            for(int j = ind; j < k; j++)\n            {\n                if(finished_time[j] <= arrival[i])\n                {\n                    ind = j;\n                    flag = 1;\n                    break;\n                }\n            }\n\n            if(!flag)\n            {\n                for(int j = 0; j < i%k; j++)\n                {\n                    if(finished_time[j] <= arrival[i])\n                    {\n                        ind = j;\n                        flag = 1;\n                        break;\n                    }\n                }\n            }\n\n            if(flag)\n            {\n                count[ind]++; // update ind th server req\n                mx = max(mx, count[ind]); // update mx_req \n                finished_time[ind] = arrival[i]+load[i]; // update the ind th srver finish time\n            }\n        }\n\n        // server have mx req are pushed in res \n        for(int i = 0; i < k; i++)\n        {\n            if(count[i] == mx) res.push_back(i);\n        }\n\n        return res;\n    }\n};\n```\n\n# Code : optimized sol\n```\nclass Solution {\npublic:\n    vector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {\n        \n        vector<int> res;\n        if(k >= arrival.size()){\n            for(int i = 0; i < arrival.size(); i++)\n                res.push_back(i);\n            return res;\n        }\n\n        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n        vector<int>count(k,1); // no. of time assign the req\n        int mx = 1; // each server have intial 1 req , so mx_req = 1\n\n        for(int i = 0; i < k; i++)\n        {\n            pq.push({arrival[i]+load[i],i});\n        }\n\n        set<int> st;\n        for(int i = k; i < arrival.size(); i++)\n        {\n            while(!pq.empty() and pq.top().first <= arrival[i])\n            {\n                st.insert(pq.top().second);\n                pq.pop();\n            }\n\n            if(st.size() > 0)\n            {\n                auto it = st.lower_bound(i%k) ;\n               \n                if(it == st.end())\n                {\n                    pq.push({arrival[i]+load[i], *st.begin()});\n                    count[*st.begin()]++;\n\n                    mx = max(mx, count[*st.begin()]);\n\n                    st.erase(st.begin()); \n                }\n                else\n                {\n                    pq.push({arrival[i]+load[i], *it});\n                    count[*it]++;\n\n                    mx = max(mx, count[*it]);\n\n                    st.erase(it); \n                }\n               \n            }\n            \n        }\n\n        // server have mx req are pushed in res \n        for(int i = 0; i < k; i++)\n        {\n            if(count[i] == mx) res.push_back(i);\n        }\n\n        return res;\n    }\n};\n```
['Greedy', 'Heap (Priority Queue)', 'Ordered Set', 'C++']