Why not numDecodings('') returns 1

  • 3

    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

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

  • 1

    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.