Ctrl K

Words With Drawn-Out Letters

Medium
People in chats like to drag letters out when they feel strongly, typing yesss instead of yes or nooooo instead of no. Split a word into groups of equal adjacent letters: wowww splits into w, o, www. A draft word can be **stretched** by repeating this step any number of times: pick a group and add more copies of its letter so that the group ends up with **three or more letters**. Letters can never be removed. You are given the string shout that the person finally typed and a list of draft words drafts. Count how many drafts can be stretched into exactly shout. For example, hey can become heyyy, but not heyy: the yy group has two letters, fewer than three.
Example 1
shout="yesss", drafts=["yes", "yess", "yees", "ye"] → 2

Both yes and yess turn into yesss by stretching the s group to three letters. yees has two es while the shout has one, and letters cannot be removed. ye has no s at all.

Example 2
shout="cool", drafts=["col", "cool"] → 1

The oo group in the shout has only two letters, fewer than three, so col cannot become cool. Only cool itself works, with nothing to stretch.

Example 3
shout="wowww", drafts=["wow", "wwow", "owww"] → 1
Constraints
  • 1 ≤ len(shout) ≤ 100
  • 1 ≤ len(drafts) ≤ 100
  • 1 ≤ len(drafts[i]) ≤ 100
  • shout and drafts[i] consist of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsA Subsequence of One Word Only MediumLongest Word by Crossing Out MediumCapitals Follow the Pattern MediumWord Growth Chain MediumOne Insertion to Match Medium
loading Python…
Input
shout="yesss", drafts=["yes", "yess", "yees", "ye"]
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.