EASYasked at 1 company

Detect Pattern of Length M Repeated K or More Times

A easy-tier problem at 43% community acceptance, tagged with Array, Enumeration. Reported in interviews at Hudson River Trading and 0 others.

Founder's read

Hudson River Trading asks this one. You're given an array and need to find if a specific pattern of length M repeats K or more consecutive times. At 43% acceptance, candidates are failing because they either brute-force every possible substring without pruning, or they misunderstand what 'consecutive' means in the problem statement. The trick isn't complex, but the off-by-one errors and boundary conditions will trip you up under interview pressure. If this hits your live assessment and you blank on the optimal pass, StealthCoder solves it in seconds invisible to the proctor.

Companies asking
1
Difficulty
EASY
Acceptance
43%

Companies that ask "Detect Pattern of Length M Repeated K or More Times"

If this hits your live OA

Detect Pattern of Length M Repeated K or More Times is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The pattern here is enumeration: you iterate through all possible starting positions and pattern lengths, then check if that pattern repeats exactly K times without interruption. Most candidates waste cycles checking patterns that can't possibly repeat K times given the remaining array length. The real gotcha is string slicing versus index arithmetic. If you use string conversion and slice notation, you'll solve it, but you'll spend mental energy on off-by-one bugs. Index-based logic is cleaner: calculate where the Kth repetition would end, validate that the substring from start to that end point equals the pattern repeated K times, then move on. Common failure mode: checking if the pattern appears K times total anywhere in the array instead of K consecutive repetitions. StealthCoder is your hedge for the one problem where the pattern definition trips you up during screen share.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Detect Pattern of Length M Repeated K or More Times recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Detect Pattern of Length M Repeated K or More Times interview FAQ

Is this really asked at HRT or just a general prep problem?+

Hudson River Trading is in the askedBy list. It's a real screen. That said, the acceptance rate is 43%, which is lower than you'd expect for 'easy' difficulty. People miss the enumeration structure or mess up the repetition check logic under time pressure. Know the pattern and you'll clear it.

What's the trick to avoid brute-force time limits?+

Don't check every substring length from 1 to N. Prune: if M (pattern length) times K (repetitions) is longer than the remaining array, skip it. Also, once you find a valid pattern, return immediately. Most solutions won't TLE if you're smart about the loop bounds, but enumerate in the right order to fail fast.

String comparison versus manual index checking: which is faster?+

For coding interviews, readability wins. String slicing and direct comparison is clear and correct. Index arithmetic is marginally faster but introduces off-by-one risk. Given this is 'easy' difficulty, the interviewer cares more about correctness than micro-optimizations. Pick the approach you trust under pressure.

How does this relate to the Array and Enumeration topics?+

Enumeration means you systematically explore all valid candidates (pattern starts, pattern lengths). Array is the data structure. You're not using a hash map or tree. It's pure iteration and substring validation. The skill being tested is systematic exploration, not a clever algorithm.

If I see a 'pattern repeat' problem on test day, what's my mental checklist?+

First, clarify: consecutive repetitions or total occurrences. Second, identify the enumeration structure: loop over all possible (start, pattern_length) pairs. Third, for each pair, validate that exactly K consecutive repetitions exist. Fourth, return as soon as you find one. Fifth, test edge cases: empty array, M=0, K=1, K larger than array length.

Want the actual problem statement? View "Detect Pattern of Length M Repeated K or More Times" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.