Company: Agoda_9nov
Difficulty: medium
Assigned Parking Problem Description There are n cars located at n 2-dimensional plane at positions (x[i], y[i]) . They need to be parked in a straight line parallel to the x-axis with no spaces between them. The fuel consumed to move a car is abs(x[finish] - x[start]) + abs(y[finish] - y[start]) . Determine the minimum total fuel cost to arrange all cars side-by-side in a row parallel to the x-axis. Complete the function minFuel in the editor with the following parameter(s): int x[n] : the x coordinates int y[n] : the y coordinates Returns: long : the minimum fuel required to move all of the cars Examples Example 1: Input: x = [1, 4], y = [1, 4] Output: 5 Explanation: One optimal solution is: Car at (1, 1) moves to (3, 1), using abs(3-1) + abs(1-1) = 2 + 0 = 2 fuel. Car at (4, 4) moves to (4, 1), using abs(4-4) + abs(1-4) = 0 + 3 = 3 fuel. The total minimum fuel cost is 2 + 3 = 5 . Example 2: Input: n = 2 x = [1, 5] y = [1, 5] Output: 7 Explanation: Initially, the cars are at points (