question archive The accessible areas are represented as 1, areas without roads are represented by 0 and the order destination is represented by 9
Subject:Computer SciencePrice:0 Bought3
The accessible areas are represented as 1, areas without roads are represented by 0 and the order destination is represented by 9.
Input
The input to the function/method consists of one argument:
Area, representing the two-dimensional grid of integers.
Output
Return an integer representing the total distance traversed to deliver the order else return-1.
Constraints
1 £ rows, columns £ 103
Example
Input:
Area =
[[1, 0, 0]
[1, 0, 0]
[1, 9, 1]
Output:
3
Explanation:
Starting from the top-left corner, the truck traversed cells (0, 0) > (2, 0) > (2, 1). The truck traversed the total distance to deliver the order.
So, the output is 3.