Why not numDecodings('') returns 1


  • 3
    G

    numDecodings('') = 0 makes sense if you think it is invalid input. But one can also argue that there is ONE AND ONLY ONE decoding in case that decoded string is '' as well.


  • 0
    S

    Let's say, LeetCode OJ defines it like this. Definitely, it should be discussed with interviewer while in a real interview.


  • 1
    W

    Agreed. Just like 0! is defined as 1. It is still one way of length 0.


Log in to reply
 

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