A message of digits 0-9 encodes letters by alphabet position: A=1, B=2, ..., Z=26. Given the digit string, count the number of distinct ways to decode it.
This entry exposes the recursive helper directly. Call dfs(startIndex, digits) to count decodings of digits starting at startIndex.
Input
startIndex: index into digits where decoding should resume
digits: the digit string (or array) being decoded
Output
The number of ways to decode digits from startIndex to the end.
Examples
Example 1
InputstartIndex = 2, digits = [10, 20]
Output1
Constraints
A single 0 cannot be decoded; a leading 0 in a two-digit pair is invalid.
Valid two-digit pairs lie in [10, 26].