Problem · Sliding Window
Max Frequency Substring
Learn this problemProblem statement
Given a string containing a number of characters, find the substrings within the string that satisfy the conditions below:
minLength, maxLength).maxUnique.Using those conditions, determine the frequency of the maximum occurring substring.
Function
getMaxFrequencySubstring(s: String, minLength: int, maxLength: int, maxUnique: int) → int
Complete the function getMaxFrequencySubstring in the editor.
getMaxFrequencySubstring has the following parameters:
String s: the string to analyzeint minLength: the minimum length of the substringint maxLength: the maximum length of the substringint maxUnique: the maximum number of unique characters in the substring
Returns
int: the frequency of the maximum occurring substring
Examples
Example 1
s = "abcde"minLength = 2maxLength = 3maxUnique = 3return = 1The given string components is 'abcde'.
The number of pieces in an interval should be greater than or equal to minLength = 2, so 'a', 'b', 'c', 'd', and 'e' are discarded.
The combination of characters should be less than or equal to maxLength = 3, so 'abcd', 'bcde', and 'abcde' are discarded.
The intervals that satisfy the conditions above are 'ab', 'bc', 'cd', 'de', 'abc', 'bcd', and 'cde'.
Each combination of characters occurs only one time, so the maximum number of occurrences is 1.
Constraints
An unknown urban legend for now 🥲More Snowflake problems
- Closest Target CharacterPHONE SCREEN · Seen Jul 2026
- Horizontal Pod AutoscalerSeen Jul 2026
- Minimum HeightOA · Seen Jul 2026
- Vowel SubstringSeen Jun 2026
- String Formation (Also for AI/ML Software Engineer Intern :)OA · Seen Jun 2026
- Efficient DeploymentsOA · Seen Jun 2026
- Character Frequencies Across Nested String ListsPHONE SCREEN · Seen Jun 2026
- Character Frequencies Across StringsPHONE SCREEN · Seen Jun 2026