Your question is Most Frequent Substring. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
HubSpot Content Hub can scan text to identify repeated fixed-length fragments for content-quality analysis. Given a lowercase string and a substring length, return the most frequent substring.
If multiple substrings have the same highest frequency, return the one whose first occurrence has the smallest index. Each occurrence is counted by its starting position, including overlapping occurrences.
Implement find_most_frequent_substring(text, k).
text, a non-empty lowercase string, and k, a positive integer.k substring with the highest number of occurrences. The output must be a string of length k.def find_most_frequent_substring(text, k):