Problem Statement | |||||||||||||
Valet parking is used to maximize the number of cars that we can park in our
lot. The parking spaces are arranged in a 100 x 100 grid of squares.
Each square can hold one car, and it is possible to drive a car onto any of the
four orthogonally adjacent squares (provided that it is not already occupied
by a car). A car may enter or leave the lot only on the corner square whose
coordinates are (0,0).
The lot is full when all but one of the squares is occupied. Given the location of the one empty square and the location of the customer's car, we want to know how many times the valet will have to get into a car and drive it before he can maneuver the customer's car to the location (0,0). The valet is not allowed to drive any of the cars out of the lot. Create a class ValetParking that contains a method minMoves that is given the coordinates (emptyRow and emptyCol) of the one empty square in the full lot, and the coordinates of the customer's car (cusRow and cusCol). The method returns the number of times the valet will have to move a car. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | emptyRow, emptyCol, cusRow, and cusCol will be between 0 and 99, inclusive. | ||||||||||||
- | (emptyRow,emptyCol) is not the same position as (cusRow,cusCol). | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|