Ways message can be decoded

This Question Was Asked By Facebook

There is a mapping a = 1, b = 2, ... z = 26 given and an encoded message. You have to count the number of ways it can be decoded.

Write a function solve that have the following parameter(s):
1.) a= string

Example
Input:
a = 111
Output:
The function will return,
3

Explanation
The message 111 would give 3, since it could be decoded as aaa, ka, and ak.

Constraints
• Mapping will be from a to z.