Rolling Hash LeetCode Problems: All 18, With Python Solutions

Every problem in this library that LeetCode tags Rolling Hash 18 in total, 13 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 18 problems
  • 0 Easy
  • 8 Medium
  • 10 Hard

Rolling Hash problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Medium (8)

#ProblemDifficultyTopics
187Repeated DNA SequencesMediumBit Manipulation, Hash Table, String +3
718Maximum Length of Repeated SubarrayMediumArray, Binary Search, Dynamic Programming +3
1461Check If a String Contains All Binary Codes of Size KMediumBit Manipulation, Hash Table, String +2
2261K Divisible Elements SubarraysMediumTrie, Array, Hash Table +3
1062Longest Repeating SubstringPremiumMediumString, Binary Search, Dynamic Programming +3
1554Strings Differ by One CharacterPremiumMediumHash Table, String, Hash Function +1
1698Number of Distinct Substrings in a StringPremiumMediumTrie, String, Suffix Array +2
2168Unique Substrings With Equal Digit FrequencyPremiumMediumHash Table, String, Counting +2

Hard (10)

#ProblemDifficultyTopics
214Shortest PalindromeHardString, String Matching, Hash Function +1
1044Longest Duplicate SubstringHardString, Binary Search, Suffix Array +3
1147Longest Chunked Palindrome DecompositionHardGreedy, Two Pointers, String +3
1316Distinct Echo SubstringsHardTrie, String, Hash Function +1
1392Longest Happy PrefixHardString, String Matching, Hash Function +1
1923Longest Common SubpathHardArray, Binary Search, Suffix Array +2
1960Maximum Product of the Length of Two Palindromic SubstringsHardString, Hash Function, Rolling Hash
2156Find Substring With Given Hash ValueHardString, Sliding Window, Hash Function +1
2430Maximum Deletions on a StringHardString, Dynamic Programming, String Matching +2
2223Sum of Scores of Built StringsHardString, Binary Search, String Matching +3

When the Rolling Hash problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.