Tap here to switch tabs
Problem
Submissions

Problem: Alphabet Board Path

med
30 min
Try to solve the Alphabet Board Path problem.

Statement

We start at position (0,0)(0, 0), which corresponds to character 'a', on an alphabet board arranged as follows:

["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"]

We can make the following types of moves:

  • 'U' moves the position up by 11 unit.

  • 'D' moves the position down by 11 unit.

  • 'L' moves the position left by 11 unit.

  • 'R' moves the position right by 11 unit.

  • '!' adds the character at the current position on the board to the spelled string.

Every move must keep the position within the valid boundaries of the board.

Given a string target, return a sequence of moves to spell out the string target. Any valid path that produces the correct result will be accepted.

Constraints:

  • 1≤1 \leq target.length ≤100\leq 100

  • target consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Alphabet Board Path

med
30 min
Try to solve the Alphabet Board Path problem.

Statement

We start at position (0,0)(0, 0), which corresponds to character 'a', on an alphabet board arranged as follows:

["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"]

We can make the following types of moves:

  • 'U' moves the position up by 11 unit.

  • 'D' moves the position down by 11 unit.

  • 'L' moves the position left by 11 unit.

  • 'R' moves the position right by 11 unit.

  • '!' adds the character at the current position on the board to the spelled string.

Every move must keep the position within the valid boundaries of the board.

Given a string target, return a sequence of moves to spell out the string target. Any valid path that produces the correct result will be accepted.

Constraints:

  • 1≤1 \leq target.length ≤100\leq 100

  • target consists only of lowercase English letters.