Minimum Length of Anagram Concatenation

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

Example 1
Inputs = "abba"
Output2
One possible string t could be "ba".
Example 2
Inputs = "cdef"
Output4
One possible string t could be "cdef"; notice that t can be equal to s.

Constraints

  • 1 <= s.length <= 10^5
  • s consist only of lowercase English letters.

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate