Trains the technique from
LeetCode 3333Find the Original Typed String IIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A label was made by pressing one stamp at a time, and a stamp held down too long leaves several copies of its letter in a row. The finished label reads word.
So the label falls into runs of one repeated letter, and a run of L letters could have come from anywhere between 1 and L presses of that stamp.
Return how many different intended labels hold at least k letters. Two intended labels differ when some run came from a different number of presses. Report the count modulo 10^9 + 7.
Example 1
The three runs each hold two letters, so eight intended labels are possible, running from three letters up to six. Only the shortest, one press per run, falls below four.
Example 2
The single run of three could have come from one, two or three presses, and the last two of those hold at least two letters.
Example 3
Neither letter repeats, so only one intended label exists, and it holds two letters.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def possible_string_count(word: str, k: int) -> int:public int possibleStringCount(String word, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.