Computer Science, asked by sursin86, 1 year ago

Count possible decodings of a given digit sequence c++

Answers

Answered by athulbiju10
0
This problem is recursive and can be broken in sub-problems. We start from end of the given digit sequence. We initialize the total count of decodings as 0. We recur for two subproblems.
1) If the last digit is non-zero, recur for remaining (n-1) digits and add the result to total count.
2) If the last two digits form a valid character (or smaller than 27), recur for remaining (n-2) digits and add the result to total count.
Similar questions