Minimum Length of Anagram Concatenation - Problem
You are given a string s, which is known to be a concatenation of anagrams of some string t. Return the minimum possible length of the string t.
An anagram is formed by rearranging the letters of a string. For example, "aab", "aba", and "baa" are anagrams of "aab".
Input & Output
Example 1 — Equal Character Frequencies
$
Input:
s = "abab"
›
Output:
2
💡 Note:
String can be split as "ab" + "ab". Both segments are anagrams of "ab", so minimum length is 2.
Example 2 — Multiple Character Pattern
$
Input:
s = "aabaab"
›
Output:
3
💡 Note:
String can be split as "aab" + "aab". Both segments are identical anagrams, so minimum length is 3.
Example 3 — Single Character
$
Input:
s = "aaaa"
›
Output:
1
💡 Note:
All characters are the same, so the minimum pattern is just "a" repeated 4 times.
Constraints
- 1 ≤ s.length ≤ 105
- s consists of lowercase English letters
Visualization
Tap to expand
Understanding the Visualization
1
Input Analysis
String s is made of concatenated anagrams
2
Pattern Detection
Find minimum length that divides string into valid anagrams
3
Result
Return the minimum possible pattern length
Key Takeaway
🎯 Key Insight: The minimum pattern length divides all character frequencies equally
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code