#1309

Decrypt String from Alphabet to Integer Mapping

newbie · 170 · lc easy +15 · verified · 80.6% accepted · 1,608 likes · top 92%

Description

Decode the string s (composed of digit characters and '#') into lowercase letters using this scheme:

- A single digit '1''9' maps to letters 'a''i'.
- A two-digit number followed by '#' (e.g., '10#''26#') maps to letters 'j''z'.

Return the decoded string. The input always has a unique valid decoding.

Example 1:

Input: s = "10#11#12"
Output: "jkab"
Explanation: "j" -> "10#" , "k" -> "11#" , "a" -> "1" , "b" -> "2".

Example 2:

Input: s = "1326#"
Output: "acz"

Code

1
2
3