Why are there “0”


  • 9
    T

    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" ?


  • 0
    S

    determine the total number of ways to decode it.

    So, if the input string is "0", the answer would be 0 as well.


  • 4
    L

    Exactly. Encoding a messing including A-Z, how can you get "0" or "100"?


  • 2
    S

    "Given an encoded message containing digits," -> so this isn't true than, because it is not 'encoded message'


  • 0

    @1337c0d3r Could you please fix the problem description or the test case?


  • 0
    J

    I also get confused why there is 0. If it exists, why, "01" is 0 and "10" is 1. The description should be clear.


  • 1
    W

    0_1483640616516_Zrzut ekranu 2017-01-05 o 19.23.24.png 0_1483640590355_Zrzut ekranu 2017-01-05 o 19.22.44.png

    Wait, aren't these two contradictory? Surely the correct answer for both is "1", but why do they differ?!


  • 1
    N

    Same problem here
    0_1484449325188_Screen Shot 2017-01-14 at 6.59.09 PM.png

    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?


  • 0
    D

    @nikhil-kathuria

    There's nothing wrong here. It reads the string as "10" and '1'.


  • 2

    @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.


  • 0
    4

    Exactly! There should never be '100' in the decoded string! Could someone fix this?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.