Company: Epam Ai native software engineer Oncampus_15july
Difficulty: medium
Valid Number Partitions Problem Description You are given a string s of n digits. Cut s into one or more contiguous pieces so that every piece, read as a decimal number, is a valid number . Count how many different ways of cutting s exist. A piece is a valid number when both of the following hold: its value is between 1 and 26 , inclusive, and it does not start with the digit 0 . So a piece is either a single digit from 1 to 9 , or two digits forming a number from 10 to 26 . A piece such as "0" , "01" or "06" is never valid, while "10" and "20" are valid. Two ways of cutting are different when the positions of the cuts differ. For example, "12" can be kept whole as 12 , or cut into 1 and 2 , so it has two valid partitions. "27" has only one ( 2 and 7 ), because 27 is greater than 26 . Complete the function num_decodings(n, s) , which receives the length n and the string s and returns the number of valid partitions of s . If no valid partition exists, return 0 . Input Format Read from s