FastPrepMaximum Valid Substring Frequency
Problems/Maximum Valid Substring Frequency

Maximum Valid Substring Frequency

Roblox logoRoblox● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The candidate names Most Frequent Substring, links a variant with distinct characters, and mentions limits on minimum and maximum length. The full statement of the reference is not available. We chose the numeric frequency, how overlaps are handled, the alphabet, and the limits. Our version is about 85% the same as the reported question.

A valid substring of s is contiguous, has length from minLength through maxLength inclusive, and contains at most maxUnique distinct letters.

For this exercise, assume occurrences at different starting positions are counted separately, including overlapping occurrences. Return the largest occurrence count of any one valid substring value. Return 0 if no substring is valid. The result is a count, so no tie rule between equally frequent substring values is needed.

Function

maxSubstringFrequency(s: String, minLength: int, maxLength: int, maxUnique: int) → int

Examples

Example 1

s = "aaaaa"minLength = 2maxLength = 3maxUnique = 1return = 4

aa occurs at four starting positions, including overlaps. aaa occurs three times, so the answer is 4.

Example 2

s = "aabcabcaab"minLength = 3maxLength = 5maxUnique = 2return = 2

aab occurs twice and uses only two distinct letters. It is a valid substring with the greatest frequency.

Example 3

s = "abc"minLength = 2maxLength = 2maxUnique = 1return = 0

Both length-2 substrings contain two distinct letters and exceed the limit 1.

Constraints

  • 1 <= s.length <= 10000; s contains lowercase English letters.
  • 1 <= minLength <= maxLength <= min(26, s.length).
  • 1 <= maxUnique <= 26.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Inventory Discount TrackerOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025

Similar questions at other companies

  • Perfect SubstringAXQ Capital · OA
  • Maximum Valid Substring FrequencyMicrosoft · OAMicrosoft interview questions
  • Longest Distinct StringSuperhuman · OASuperhuman interview questions
  • Longest Substring Without Repeating CharactersAkuna Capital · OAAkuna Capital interview questions
  • Perfect SubstringsVisa · OAVisa interview questions
  • Vowel SubstringSnowflake · OASnowflake interview questions
  • Count Distinct Fixed-Length SubstringsAdobe · OAAdobe interview questions
  • Video ID Generation (Generic)TikTok · OATikTok interview questions
  • Unaligned DedupeRubrik · OARubrik interview questions
  • Get Max OccurrencesIBM · OAIBM interview questions

Interview reports that mention this question

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)

Roblox interview experiences

  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int maxSubstringFrequency(String s, int minLength, int maxLength, int maxUnique) {
        // write your code here
    }

}
Checking account…