Myntra Customer Service Request Prioritizer
Myntra's customer support system handles a continuous stream of customer requests. To maintain high service standards and address critical issues efficiently, requests marked as "escalated" must be prioritized over "normal" requests. This problem focuses on implementing a system to reorder incoming requests based on their priority before they are dispatched to agents.
You are tasked with implementing a function that takes an array of customer support request objects. Each request has a unique ID and a priority level. Your function must return an array of requestIds, reordered according to the following rules:
priority: 'escalated' must appear before any requests with priority: 'normal'.The function prioritizeRequests will take one parameter:
requests: An array of objects, where each object represents a customer support request.
requestId (number): A unique identifier for the request.priority (string): Can be either 'normal' or 'escalated'.The function must return:
requestIds in their prioritized order.requests array will not be empty.requestIds are guaranteed to be unique.priority field will only ever be 'normal' or 'escalated'.Examples
Example 1
Input:
requests = [{"requestId": 101, "priority": "normal"}, {"requestId": 102, "priority": "escalated"}, {"requestId": 103, "priority": "normal"}, {"requestId": 104, "priority": "escalated"}]
Output:
[102, 104, 101, 103]
Note:
Requests 102 and 104 are escalated and appear first, maintaining their original relative order. Requests 101 and 103 are normal and appear after, also maintaining their original relative order.
Example 2
Input:
requests = [{"requestId": 201, "priority": "normal"}, {"requestId": 202, "priority": "normal"}, {"requestId": 203, "priority": "normal"}]
Output:
[201, 202, 203]
Note:
All requests are normal, so their original order is preserved.
Example 3
Input:
requests = [{"requestId": 301, "priority": "escalated"}, {"requestId": 302, "priority": "escalated"}, {"requestId": 303, "priority": "escalated"}]
Output:
[301, 302, 303]
Note:
All requests are escalated, so their original order is preserved.
Constraints
1 <= requests.length <= 10001 <= requestId <= 10^9Loading editor...