Round 1
Questions:
-
vector<int> findRequestTarget(int num_servers, vector<int> requests) { int n = num_servers; vector<int> answer; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; for(int i = 0; i < n; i++) { pq.push({0, i}); } for(auto x : requests) { vector<int> temp; while(pq.size() && pq.top().second > x) { temp.push_back(pq.top()); pq.pop(); } pair<int, int> curr = pq.top(); pq.pop(); answer.push_back(curr.second); curr.first++; pq.push({curr.first, curr.second}); for(auto y : temp) { pq.push(y); } } return answer; }
Candidate's Approach
The candidate implemented a priority queue to manage server requests. They initialized the queue with servers and processed requests based on their timing. However, they encountered a Time Limit Exceeded (TLE) error, indicating that the solution may not be efficient enough for larger inputs.
Interviewer's Feedback
No feedback provided.
![image](https://assets.leetcode.com/users/images/7959d18c-88f2-42a7-8535-8dd82a939678_17378