I have tried to solve this problem for about 2 hours. I am not capable of solving. Does anyone have an idea on how to go about solving it? I tried using Python v. 3+
Any help would be greatly appreciated:
Given a two-dimensional array of letters, find the longest path that you can create by moving between adjacent letters in the alphabet - for example, if you are on a D, you may move to an E or a C. You may move up, down, left, or right by a single row or column, but not diagonally or more than one space. You may start at any square, and you may only use a given row/column pair once.
Return an ordered list of row/column pairs that represents the longest path. If there is a tie between two paths, return the one that starts with the lowest row index, and if that is also a tie, use the one with the lowest row and column indices. (If there is still a tie, returning either path is acceptable.)
Example input
A B H F
C C D G
A B D F
Example output
ABCBA
Clarifications The array will always contain at least one value. A and Z are not considered ‘adjacent’ letters. All lines will contain the same number of letters.