Reported July 2024
Amazonstring

Get Redundant Substrings

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

Amazon's substring problem in July 2024 is a pattern-matching gauntlet. You're staring at a string and need to find redundant substrings or reconstruct a string from a compressed or repeated pattern. The catch: it's not always obvious which substrings are truly redundant versus which ones just look the same. This is a hash-table and string-parsing problem dressed up as optimization. StealthCoder will spot the pattern when you blank on the exact substring range.

Pattern and pitfall

The core trick is recognizing that a 'redundant' substring usually means a pattern that repeats or can be factored out. You'll iterate through possible substring lengths, check if the string can be built by repeating that substring, and track which ones work. Hash tables are your friend here: store substring hashes or use rolling hashes to detect repetition in linear time. The pitfall is brute force substring enumeration without memoization, which tanks performance on large strings. StealthCoder will feed you the hash-based approach or the KMP-derived pattern-matching trick if you get stuck mid-solution.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Get Redundant Substrings cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Redundant Substrings FAQ

What counts as a 'redundant' substring in Amazon's version?+

Usually a substring that appears consecutively (like 'abab' from 'ab'), or the whole string can be expressed as repetitions of a smaller pattern. Amazon tends to ask for the shortest such pattern or count of redundancies. Read the problem carefully for whether it's asking for patterns or actual substring instances.

Do I need to use hashing or can I compare strings directly?+

String comparison works for small inputs but fails on large strings (1M+ chars). Use rolling hash (polynomial or Rabin-Karp) to check repetition in O(n) instead of O(n^2). Most Amazon OAs will have a size constraint that punishes brute force.

Is this the 'repeating substring pattern' LeetCode problem?+

Likely yes or a variant. The classic is checking if a string is made of repeated patterns (KMP table trick). Amazon sometimes adds a twist: return the shortest pattern, count non-overlapping occurrences, or identify which substrings are redundant. Know the KMP approach cold.

How do I prep for this in 24 hours?+

Practice the repeating substring pattern problem. Understand KMP failure function or why n % pattern_length == 0 matters. Code a rolling-hash solution once. Then stop and get sleep. You don't have time to master every edge case.

What's the fastest approach if I'm blanking live?+

Check divisors of string length. For each divisor d, extract the first d characters as a candidate pattern and check if the whole string equals that pattern repeated. It's O(n) with simple loops, no fancy hashing required, and it works most of the time.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it