leetle

Daily challenge for 2025-06-04

155. Decode Ways

Write a function solve that determines the number of ways to decode a string of digits. A message containing letters from A-Z can be encoded into numbers by mapping A to 1, B to 2, ..., Z to 26. For example, the message 'ABC' would be encoded as '123'.

Given a string of digits, return the number of ways to decode it.

Example:
Input: "12"
Output: 2
Explanation: "12" could be decoded as "AB" (1 2) or "L" (12).

Run this challenge interactively in Python or JavaScript when the app loads.