#3324

Find the Sequence of Strings Appeared on the Screen

pupil · 450 · lc medium +26 · 80.2% accepted · 139 likes · top 92%

Description

You are given a string target.

Alice wants to type target on a keyboard that has only two keys:

- Key 1 appends the letter "a" to the current string on screen.

- Key 2 advances the last character of the on-screen string to the next letter in the alphabet (for example, "c" becomes "d", and "z" wraps back to "a").

The screen starts empty, so only Key 1 can be pressed first.

Return a list of every string that appears on the screen as Alice types target using the fewest possible keystrokes, in the order each string appears.

Code

1
2
3