Company: Nk securities
Difficulty: medium
Maximum Earnings Problem Description A taxi driver knows the pick-up and drop-off locations of people who are requesting taxi services. All the locations are in km from the starting point. The starting point is at 0 km. For each km travelled by a passenger, the driver charges 1 unit of money per passenger. Moreover, the taxi itself is very fancy. Therefore some people are even willing to pay an extra tip if they get to travel in the taxi. At any point of time, the taxi can only accommodate one passenger. Determine the maximum amount the driver can earn. Examples Example 1: Input: pickup = [0, 2, 9, 10, 11, 12], drop = [5, 9, 11, 11, 14, 17], tip = [1, 2, 3, 2, 2, 1] Output: 20 Explanation: The way to earn the most money is by accepting passengers at indices 1, 2 and 5. The amount paid by the passenger at index 1: 9 - 2 + 2 = 9 The amount paid by the passenger at index 2: 11 - 9 + 3 = 5 The amount paid by the passenger at index 5: 17 - 12 + 1 = 6 The total amount paid by the passengers