2. Busy intersection There is a busy intersection between two one-way streets: Main Street and 1st Avenue. Cars passing through the intersection can only pass through one at a time. When multiple cars arrive at the intersection at the same time, two queues can build up - one for each street. Cars are added to the queue in the order at which they arrive. Unfortunately, there is no traffic light to help control traffic when multiple cars arrive at the same time. So, the local residents have devised their own system for determining which car has priority to pass through the intersection: - If in the previous second, no car passed through the intersection, then the first car in the queue for 1 st Avenue goes first. - If in the previous second, a car passed through the intersection on 1st Avenue, then the first car in the queue for
1st
Avenue goes first. - If in the previous second, a car passed through the intersection on Main Street, then the first car in the queue for Main Street goest first. Passing through the intersection takes 1 second. For each car, find the time when they will pass through the intersection. Function Description Complete the function getResult in the editor below. getResult has the following parameters: int arrival [n]: an array of
n
integers where the value at index
i
is the time in seconds when the
i th car arrives at the intersection. If arrival[i]
=
arrival[j] and
i , then car
i
arrives before car
j
. int street[n]: an array of
n
integers where the value at index
i
is the street on which the
t th car is traveling: Street and 1 for 1 st Avenue. Returns:
int[n]:
an array of
n
integers where the value at index
i
is the time when the
i th car will pass through the intersection Constraints -
1≤n≤10 5
-
0≤arrival[i]≤10 9
for
0≤i≤n−1
- arrival[i]

arrival[i
+1]
for
0≤i≤n−2
-
0≤s
street
[i]≤1
for
0≤i≤n−1



Answer :