Reported September 2026
Visahash table

Minimum Anagram Period

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

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

A frequency table is the whole game in this Visa OA question, reported in September 2026. Minimum Anagram Period hands you a lowercase string and asks for the smallest block length that splits it into blocks that are all anagrams of each other. It looks like string slicing, but it's really a hash-table counting problem with a divisor loop on top. If you have an invite in your inbox, this is a good one to see coming. And if you blank mid-assessment, StealthCoder sits invisibly on your screen as a safety net and hands you the approach.

The problem

You are given a string inputStr containing lowercase English letters.
Choose a positive block length p that divides inputStr.length. Split the entire string into consecutive blocks of length p. A block length is valid when every block is an anagram of every other block, meaning that all blocks have identical character frequencies.
Return the minimum valid block length.

Function
getAnagramPeriod(inputStr: String) → int

Examples
Example 1
inputStr = "abcbcacba"
return = 3
Split the string into abc, bca, and cba. The three blocks are anagrams, and no smaller block length works.
Example 2
inputStr = "ababbaab"
return = 2
The blocks are ab, ab, ba, and ab. Every block has one a and one b.
Example 3
inputStr = "aaaa"
return = 1
Every one-character block is the string a, so the minimum valid length is 1.

Constraints
1 <= inputStr.length <= 10^5.
inputStr contains only lowercase English letters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: p must divide n, so only test divisors of the length. For each divisor, count characters in the first block with a 26-slot array or hash map, then compare every following block against that count. Return the first divisor that passes, going in ascending order. Cost is the number of divisors times n, and n is at most 10^5, so that's fast. The common pitfall is sorting every block, which adds a log factor and wastes time. Another is testing lengths that don't divide n, which leaves a ragged last block. Also remember p = n always works, so you always have an answer. A cheap early exit helps too: if any character's total count isn't divisible by n/p, skip that p immediately. StealthCoder is the hedge if the divisor loop slips your mind live, but the logic is small enough to hold in your head.

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 Minimum Anagram Period 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 Visa's OA.

Visa 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.

Minimum Anagram Period FAQ

What's the trick to Minimum Anagram Period?+

Only try block lengths that divide the string length. For each one, build a character frequency count from the first block and check that every other block matches it. The first divisor that passes is your answer. The full string always works as one block, so you never return nothing.

How hard is this one really?+

Easy to medium. There's no clever data structure beyond a 26-slot count array. Most of the difficulty is remembering to restrict to divisors and keeping the comparison linear. If you've written an anagram check before, you've basically written this.

What's the time complexity I should aim for?+

Roughly O(d * n), where d is the number of divisors of n. For n up to 10^5, d is small, at most a few hundred, so it runs comfortably. Sorting each block would add a log factor you don't need, so stick with counting.

Should I use a hash map or a fixed array?+

Use a fixed array of 26 integers since the input is lowercase letters only. It's faster and compares easily. A hash map works too, but comparing maps costs more and adds nothing here. Reset or rebuild the count per block, then compare against the first block's count.

How do I prepare for this in 48 hours?+

Write the solution once from scratch. Practice listing divisors up to the square root of n, then a block comparison with a count array. Test it on the three examples, including the all-same-letter case that returns 1. Then do a couple of similar string-frequency problems so the pattern feels automatic.

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

OA at Visa?
Invisible during screen share
Get it