bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumArrays & HashingLC 809

Expressive Words

Sometimes people repeat letters to represent extra feeling. For example: "hello " -> "heeellooo " "hi " -> "hiiii " In these strings like "heeellooo ", we have groups of adjacent letters that are all the same: "h ", "eee ", "ll ", "ooo ". You are given a string s and an array of query strings words. A query word is stretchy if it can be made to be equal to s by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is three or more. For example, starting with "hello ", we could do an extension on the group "o " to get "hellooo ", but we cannot get "helloo " since the group "oo " has a size less than three.

Asked at 1 company
Google
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode