Find number of ways a string can be decoded into, if A=1, B=2, C=3 ... Z=25 and encoding number is 123 ways decoding can be done is
1 2 3 = A B C
1 23 = A X
12 3 = L C
1 2 3 = A B C
1 23 = A X
12 3 = L C
[1]
/ \
[2] [3]
/ \ / \
[4] [5] [6] [7]
/
[8]
Here Output should be 1, and 2 for K=2 as both are at 2 distance from leaf nodes.