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" ?
determine the total number of ways to decode it.
So, if the input string is
"0", the answer would be
0 as well.
"Given an encoded message containing digits," -> so this isn't true than, because it is not 'encoded message'
@1337c0d3r Could you please fix the problem description or the test case?
I also get confused why there is 0. If it exists, why, "01" is 0 and "10" is 1. The description should be clear.
Wait, aren't these two contradictory? Surely the correct answer for both is "1", but why do they differ?!
Same problem here
The expected answer for both 10 or 110 is 1 whereas the expected answer for 1100 is 0. Even for say 50 or 500, it is again 0. Cannot find a pattern to fix the issue. Am I missing something here?
There's nothing wrong here. It reads the string as "10" and '1'.
@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.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.