Decode Ways

Intercept a secret message encoded as a string of numbers. The message is decoded using mappings from 1 to 26 corresponding to letters A to Z. Some codes overlap, creating multiple decoding options. Return the number of possible decoding ways for the given string s. If decoding is not possible, return 0.

Constraints

  • 1 <= s.length <= 100
  • s contains only digits and may contain leading zero(s).
Saving… · 2 lines
class Solution:
def decodeWays(self, s: str) -> int:
Console

Click Run to execute sample tests.