There is a sentence in question:
Given an encoded message containing digits, determine the total number of ways to decode it.
But what message can be encoded to "0" ?
@nikhil-kathuria The reason why input "10"
has expected output of 1
is because "10"
could be decoded as "J"
, same thing happens to "12"
,which could be decoded as L
by combining these 2 digits .however, since the input of 100
has one more zero than 10
, it could not find a non-zero digit to before it to be decoded in combination, thus there is no way to decode 100
. So the output is 0
. It takes me a while to understand this trick, this question is very ambiguous.