Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 91 Decode Ways - The Choices

One or two digits

At each position, you have up to two choices:

1.1. Take one digit (if it's 11-99, not 00)

2.2. Take two digits (if they form 1010-2626) For "226226": at position 00, you can take "22" (valid) or "2222" (valid). At position 11, you can take "22" (valid) or "2626" (valid). These choices branch out into different decodings. This branching, choosing one or two digits, is the core recursive structure of the problem.