You will be given a 2-dimensional grid of letters.
Write a method to find the length of the longest path of consecutive letters, starting at 'A'.
Paths can step from one letter in the grid to any adjacent letter (horizontally, vertically, or
diagonally).
For example, in the following grid, there are several paths from 'A' to 'D', but none from 'A' to 'E':
{ "ABE",
"CFG",
"BDH",
"ABC" }
One such path is:
A B .
C . .
. D .
. . .
(spaces are for clarity only)
so, for this grid, your method should return 4.
|