(SOLVED) python or C++
Discipline: IT
Type of Paper: Question-Answer
Academic Level: Undergrad. (yrs 3-4)
Paper Format: APA
Question
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 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 integers where the value at index is the time in seconds when the car arrives at the intersection. If arrival[i] arrival[j] and , then car arrives before car . int street[n]: an array of integers where the value at index is the street on which the car is traveling: Street and 1 for 1 st Avenue. Returns: an array of integers where the value at index is the time when the car will pass through the intersection Constraints - - for - arrival[i] arrival[i for - street for
- Explanation for step 1