You are given a string s of length n.
You have a faulty keyboard with keys comprising of all lowercase English alphabets. Whenever a key is pressed, the corresponding letter gets printed one or more times.
Determine the number of strings which when typed using this keyboard, may produce the given strings. Since, the number of strings can be large enough, print the number of strings modulo ( 10^9 +7 )
Example:
Input :
5
aabbc
Output :
4
( abc, aabc,abbc,aabbc )
Please provide a python implementation for the same
def solve(n, s):
buff, x, cv = s[0], 1, 1
for i in range(1,n):
if buff == s[i]:
cv += 1
else:
x *= cv
cv, buff = 1, s[i]
return x*cv
n = input() #5
s = input() #aabbc
print(solve(n,s))