Agree. For those abnormal input, also need to return 0, like '2002', '0123' and '3021'
The question's following mapping is:
'A' -> 1
'B' -> 2
'Z' -> 26
There is no "" in it.
So, "" is also abnormal input, which need to return 0, like '2002', '0123' and '3021'
I think the reason they didn't care about abnormal input is this:
"Given an encoded message containing digits", no letter indicates "0",
So there is no way you can encode a message to: "2002" or "0123"
@JellyDG But actually, "0" is one of their test cases.
The task is
Given an encoded message containing digits, determine the total number of ways to decode it.
So the input string MUST BE a valid encoded message. Otherwise the task could be formulated like this:
Given a string (containing digits), determine the total number of ways to decode it, or return 0 if it is not a valid encoded message.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.