Given a string **s**. Let **k** be the maximum number of partitions possible of the given string with each partition starts with a distinct letter. The task is to find the number of ways string **s **can be split into **k** partition (non-empty) such that each partition starts with a distinct letter. Print number modulo 1000000007

**Input:**

The first line contains an integer **T, **the number of test cases. For each test case, there is a string **s. **

**Output:**

For each test case, the output is the maximum number of ways modulo 1000000007.

**Constraints:**

1<=T<=100

1<=s.length()<=10^3

'A'<=s[i]<='z'

**Note: **String is not case sensitive.

**Example:
Input**

2

abB

abbcc

2

4

**Explanation
1. ** "abB" can be maximum split into 2 partitions {a, bB} with distinct starting letter, so k = 2. And, the number of ways to split "abb" into 2 partitions with distinct starting letter is 2 that are {a, bB} and {ab, B}.

Author: Vanshika_pec

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

murli01 | 343 |

decoder_101 | 274 |

john_wick | 204 |

singhalsaurav1997 | 196 |

Sulagna | 189 |

john_wick | 725 |

PiyushPandey4 | 717 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

decoder_101 | 512 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.