Count decodings of a numeric string
Company: Snapchat
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Onsite
Quick Answer: This question evaluates dynamic programming and string-processing skills, along with attention to edge-case handling, modular arithmetic for large results, and online algorithm design for streaming input.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('12',)
Expected Output: 2
Explanation: AB or L.
Input: ('226',)
Expected Output: 3
Explanation: Three decodings.
Input: ('06',)
Expected Output: 0
Explanation: Invalid leading zero.
Input: ('10',)
Expected Output: 1
Explanation: Only J.
Hints
- Model object-style prompts as arrays or operation streams when needed.
- Handle empty and boundary cases before the main logic.