Round 1
Questions:
- Similar to this - Amazon OA Task Scheduler
- Given the positions of trucks moving towards an end station (gas station) and a second array indicating extra gas station positions in 1-indexing, calculate the total distance traveled by all the trucks.
Example:
Gas stations: [0,2,5,9,12,18]
Extra gas stations: [[2,5],[1,3]]
The answer to be returned is [12,18].
Candidate's Approach
- For the second question, the candidate was able to solve it in O(n^2) time complexity.
- They used one for loop to traverse the gas station array and a second loop to calculate the total distance traveled.
- However, they encountered time complexity issues in 6-7 test cases and were unsure how to optimize their solution further.
Interviewer's Feedback
No feedback provided.