Decode a password string into letters
Company: Instacart
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
Quick Answer: This question evaluates string parsing and encoding/decoding skills, specifically mapping numeric tokens and handling delimiter characters within the Coding & Algorithms domain and focusing on practical implementation-level string manipulation.
Constraints
- 1 <= len(s) <= 1000
- s contains only digits and '#'
- The input is guaranteed to be a valid encoding
- Every '#' appears as part of a valid token from "10#" to "26#"
Examples
Input: ("10#11#12",)
Expected Output: "jkab"
Explanation: "10#" maps to 'j', "11#" maps to 'k', "1" maps to 'a', and "2" maps to 'b'.
Input: ("1326#",)
Expected Output: "acz"
Explanation: "1" maps to 'a', "3" maps to 'c', and "26#" maps to 'z'.
Input: ("1",)
Expected Output: "a"
Explanation: Single-character edge case: "1" maps directly to 'a'.
Input: ("26#",)
Expected Output: "z"
Explanation: Boundary two-digit code: "26#" maps to 'z'.
Input: ("123456789",)
Expected Output: "abcdefghi"
Explanation: There are no '#' characters, so each digit from 1 to 9 maps individually.
Input: ("20#1",)
Expected Output: "ta"
Explanation: "20#" maps to 't', followed by "1" which maps to 'a'.
Hints
- When parsing from left to right, check whether the current position starts a two-digit code followed by '#'.
- The numeric value 1 maps to 'a', 2 maps to 'b', and so on; converting with character arithmetic can help.