Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 1.51 KB

File metadata and controls

30 lines (23 loc) · 1.51 KB

< 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.