Medium
Quiz
#91 Decode Ways
APPROACH
A digit string encodes a message using the mapping 1→A, 2→B, …, 26→Z. Groups of digits form letters, but leading zeros are invalid (e.g., "06" is not a valid encoding). Given digit-only string s, return the total number of valid decodings, or 0 if none exist. The answer fits in a 32-bit integer.
1 of 4
1:00
What is the optimal approach for this problem?