Decrypt String from Alphabet to Integer Mapping - Problem
You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:
Characters ('a' to 'i') are represented by ('1' to '9') respectively.
Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.
Return the string formed after mapping.
The test cases are generated so that a unique mapping will always exist.
Input & Output
Example 1 — Basic Mixed Pattern
$
Input:
s = "10#11#12"
›
Output:
"jkab"
💡 Note:
10# maps to 'j' (10th letter), 11# maps to 'k' (11th letter), then we have '12' remaining without #, so these are processed as individual digits: 1→'a', 2→'b'. Final result: jkab
Example 2 — Only Single Digits
$
Input:
s = "1326#"
›
Output:
"acz"
💡 Note:
1→'a', 3→'c', 26#→'z' (26th letter). The digits 1 and 3 are single digits since they're not part of a ## pattern.
Example 3 — Only Hash Patterns
$
Input:
s = "25#"
›
Output:
"y"
💡 Note:
25# maps to 'y' (25th letter of alphabet). This is the simplest case with just one encoded character.
Constraints
- 1 ≤ s.length ≤ 1000
- s consists only of digits and the '#' letter
- s will be a valid string such that mapping is always possible
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code