Skip to content

Files

Latest commit

author
Shuo
Nov 27, 2021
cb30580 · Nov 27, 2021

History

History

count-pairs-of-equal-substrings-with-minimum-difference

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 27, 2021

README.md

< Previous                  Next >

Related Topics

[Greedy] [Hash Table] [String]

Hints

Hint 1 If the chosen substrings are of size larger than 1, then you can remove all but the first character from both substrings, and you'll get equal substrings of size 1, with the same a but less j. Hence, it's always optimal to choose substrings of size 1.
Hint 2 If you choose a specific letter, then it's optimal to choose its first occurrence in firstString, and its last occurrence in secondString, to minimize j-a.