Minimum Anagram Period
Updated
Problem statement
You are given a lowercase string inputStr.
Choose a positive block length p that divides inputStr.length. Split the string into consecutive blocks of length p. The length is valid when every block is an anagram of every other block.
Return the minimum valid block length.
Function
getAnagramPeriod(inputStr: String) → intExamples
Example 1
inputStr = "ababbaab"return = 2Split the string into ab, ab, ba, and ab. All four blocks are anagrams, and no block length smaller than 2 works.
Example 2
inputStr = "abcabc"return = 3The two blocks abc and abc match. Lengths 1 and 2 do not produce blocks with equal character counts.
Example 3
inputStr = "aaaa"return = 1Every one-character block is the string a.
Constraints
1 <= inputStr.length <= 10^5.inputStrcontains only lowercase English letters.
More Wells Fargo Online Assessment questions
- Server Upgrade PlanningOA · Seen Nov 2026
- Student and Course EnrollmentOA · Seen Nov 2026
- Bond Interest Summary Above 3%OA · Seen Oct 2026
- Count Phrases Formed by Anagram ReplacementOA · Seen Oct 2026
- Event Statistics AggregatorOA · Seen Sep 2026
- Ordered Deployment Configuration ValidatorOA · Seen Sep 2026
- Longest Subsequence That Is a SubstringOA · Seen Jul 2026
- Overloaded Game Account InventoriesOA · Seen Jul 2026
- Count Server ReplacementsOA · PHONE SCREEN · Seen Feb 2026
- Minimum Remaining LengthOA · PHONE SCREEN · Seen Feb 2026
Similar questions at other companies
- Minimum Anagram PeriodVisa · OAVisa interview questions
- Maximum Equal Parts for PrefixesAmazon · OA
- Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
- Reconstruct Digits from Jumbled English WordsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Text Embedding and Vector SearchNike, Inc. · PHONE SCREEN · ONSITE INTERVIEWNike, Inc. interview questions
- Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
- Fraction to Recurring DecimalGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Find Accounts with Negative Converted BalancesStripe · PHONE SCREENStripe interview questions
- N-gram Language Model with Add-Alpha SmoothingGoogle · ONSITE INTERVIEWGoogle interview questions
- Rank Bipedal Dinosaurs by SpeedMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions