Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 91 Decode Ways - Edge Cases

Leading zeros

The tricky part: '00' cannot be decoded alone. There's no letter for 00. If you're at a '00', you can't take one digit. You must have come from a valid two-digit combination (1010 or 2020). "0606" has 00 ways (can't start with 00). "1010" has 11 way (only "J"). "2727" has 11 way (only "BG", since 2727 > 2626).

These edge cases are where most people make mistakes. Take time to work through examples.