John is teaching his son Rob English alphabet and number counting. He reperesents 'a' as the 1st character, 'b' as the 2nd character up to 'z' as the 26th character. John says 'kite' can be representd as '119205'. The 11th character is 'k', 9th character is 'i', 20th character is 't' and 5th character is 'e'.
Rob being smarter than him, says '119205' can also mean 'aaite' (1)(1)(9)(20)(5), 'aste'(1)(19)(20)(5), etc. Now being enthusiastic about it, John wants to know given a string os length n containing digits from 0 to 9, how many such words are possible.
Input Format
You are given a string S containing characters from 0-9. You have to find how many such words are possible for that given number sequence,
Output Format
A single integer returning the number of words. If there are no possible combinations output will be 0.
🪻ଓ༉ Credit to ᡣ𐭩Full Stack Devᡣ𐭩 𓇢𓆸
Example 1:
Input: S = "2112"
Output: 5
Explanation:2112 can be represented as: (2)(1)(1)(2) is represented as baab (2)(1)(12) is represented as bal (2)(11)(2) is represented as bkb (21)(1)(2) is represented as uab (21)(12) is represented as ul Therefore, the answer in this case is 5 :)
Example 2:
Input: S = "2101"
Output: 1
Explanation:(2)(10)(1) is the only solution. Heads up 🙌 Do not consider (01) to be 'a' as this can be chained to (001), (0001).
💃💃
input:
output: