bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
EasyArrays & HashingLC 1078

Occurrences After Bigram

Given two strings first and second, consider occurrences in some text of the form "first second third ", where second comes immediately after first, and third comes immediately after second. Return an array of all the words third for each occurrence of "first second third ".

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