Decode Ways Problem
Decode Ways Problem — ExecCode Medium DSA Practice
Solve the Decode Ways problem on ExecCode. Free online medium DSA practice in Data Structures and Algorithms. Write and run code in Java, C++, Python — no signup required to run.
Problem description
A message of letters A-Z can be encoded into digits using the mapping 'A' -> 1, 'B' -> 2, ..., 'Z' -> 26. Given a string s of digits, return the number of ways to decode it. A substring may only be interpreted as a letter code if it does not start with a leading zero.
Examples
Input s = "1221"; Output 5. Input s = "12"; Output 2. Input s = "226"; Output 3
Constraints
1 ≤ s.length ≤ 100 s consists of digits and may contain leading zeros.
Practice Decode Ways free on ExecCode. Browse DSA problems, topic map, and placement guides.