mediumHash TableString 0 views
Alphabet Board Path
On an alphabet board, we start at position (0, 0), corresponding to character board[0][0].
On an alphabet board, we start at position (0, 0), corresponding to character board[0][0].
Here, board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"], as shown in the diagram below.
We may make the following moves:
(Here, the only positions that exist on the board are positions with letters on them.)
Return a sequence of moves that makes our answer equal to target in the minimum number of moves. You may return any path that does so.
Example 1
Input: target = "leet"
Output: "DDR!UURRR!!DDD!"
Example 2
Input: target = "code"
Output: "RR!DDRR!UUL!R!"
Constraints
- 1 <= target.length <= 100
- target consists only of English lowercase letters.
Hints
Companies
No companies reported yet.
Discussion
Sign in to join the discussion.
Loading discussion...
Test results
No test cases yet.