A message of letters A-Z is represented as numbers: , , ..., . Given a string of digits like "", count how many ways you can decode it. "" can be "BZ" (,), "VF" (,), or "BBF" (,,).
That's ways. Before reading on, think: at each position, what choices do you have? And when is a choice invalid? Read the problem statement carefully, noting the constraints. Try to identify the recursive structure before looking at the solution.