bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
HardBit ManipulationLC 411

Minimum Unique Word Abbreviation

A string can be abbreviated by replacing any number of non-adjacent substrings with their lengths. For example, a string such as "substitution " could be abbreviated as (but not limited to): "s10n " ( "s ubstitutio n ") "sub4u4 " ( "sub stit u tion ") "12 " ( "substitution ") "su3i1u2on " ( "su bst i t u ti on ") "substitution " (no substrings replaced) Note that "s55n " ( "s ubsti tutio n ") is not a valid abbreviation of "substitution " because the replaced substrings are adjacent. The length of an abbreviation is the number of letters that were not replaced plus the number of substrings that were replaced.

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