#3333

Find the Original Typed String II

candidate master · 1560 · lc hard +32 · 45.6% accepted · 503 likes · top 29%

Description

Alice is trying to type a specific string but sometimes holds a key too long, causing a character to repeat.

You are given a string word showing what Alice ended up typing, and a positive integer k.

Return the count of distinct original strings Alice could have intended to type, provided the intended string has length at least k.

Since the answer may be very large, return it modulo 109 + 7.

Code

1
2
3