You are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space. You are also given the array target where target = [targetX, targetY] represents your target position (targetX, targetY).
The cost of going from a position (x1, y1) to any other position in the space (x2, y2) is |x2 - x1| + |y2 - y1| (Manhattan distance).
There are also some special roads. You are given a 2D array specialRoads where specialRoads[i] = [x1i, y1i, x2i, y2i, costi] indicates that the ith special road goes in one direction from (x1i, y1i) to (x2i, y2i) with a cost equal to costi. You can use each special road any number of times.
Return the minimum cost required to go from (startX, startY) to (targetX, targetY).
Input & Output
Constraints
- start.length == 2
- target.length == 2
- 1 ≤ specialRoads.length ≤ 200
- specialRoads[i].length == 5
- start[i], target[i], specialRoads[i][j] are integers
- 1 ≤ start[i], target[i], specialRoads[i][j] ≤ 10⁵