Get Total Requests
Developers at Amazon have their applications deployed on n servers. Initially, the ith server has an id server[i] and can handle server[i] requests at a time.
For maintenance purposes, some servers are replaced periodically. On a jth day, all the servers with id equal to replaced[j] are replaced with servers with id newId[j] that can serve newId[j] requests. The total number of requests served on a jth day is the sum of the ids of the servers that the application is running on.
Given server, replaced, and newId, find the total number of requests served by the servers each day.
Note: The indices i and j are assumed to follow 1-based indexing.
Complete the function getTotalRequests in the editor.
getTotalRequests takes the following arguments:
- 1.
int server[n]: the initial server ids - 2.
int replaced[n]: the ids of the servers to replace - 3.
int newId[n]: the new ids of the replaced servers
Returns
int[]: an array of integers representing the total number of requests served each day
1Example 1

Day 1: The servers are [20, 10]. Server with id 10 is replaced by a server with id 20. New servers are [20, 20]. Total requests = 20 + 20 = 40.
Day 2: The servers are [20, 20]. Server with id 20 is replaced by a server with id 1. New servers are [1, 1]. Total requests = 1 + 1 = 2.
Hence the answer is [40, 2].
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 1051 <= server[i], replacedId[i], newID[i] <= 104