Tap here to switch tabs
Problem
Submissions

Problem: Find the Original Typed String II

med
30 min
Try to solve the Find the Original Typed String II problem.

Statement

Alice is typing a string on her keyboard. During typing, she may hold down a key for too long, causing a character to be typed multiple times consecutively.

You are given a string word representing the final text displayed on the screen, and an integer k.

For every consecutive group of identical characters in word, Alice originally intended to type that character between 11 and the count of that character in the group times.

Return the total number of possible original strings Alice could have intended to type such that the length of the string is at least k. Since the answer may be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq word.length ≤5imes105\leq 5 imes 10^5

  • word consists only of lowercase English letters.

  • 1≤1 \leq k ≤2000\leq 2000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Original Typed String II

med
30 min
Try to solve the Find the Original Typed String II problem.

Statement

Alice is typing a string on her keyboard. During typing, she may hold down a key for too long, causing a character to be typed multiple times consecutively.

You are given a string word representing the final text displayed on the screen, and an integer k.

For every consecutive group of identical characters in word, Alice originally intended to type that character between 11 and the count of that character in the group times.

Return the total number of possible original strings Alice could have intended to type such that the length of the string is at least k. Since the answer may be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq word.length ≤5imes105\leq 5 imes 10^5

  • word consists only of lowercase English letters.

  • 1≤1 \leq k ≤2000\leq 2000