Skip to main content
Back to problems
Leetcode
Medium
Hash Maps
Strings
Math
Redistribute Characters To Make All Strings Equal

Determine whether the characters from all given strings can be redistributed so that every string becomes identical.

Acceptance 0%
Problem Statement

Redistribute Characters to Make All Strings Equal

You are given an array of strings. You may take characters from any string and redistribute them among the strings in any way you want, as long as the total multiset of characters stays the same.

Your task is to determine whether it is possible to make every string in the array exactly the same after redistribution.

In other words, after rearranging and moving characters across strings, each string should end up with the same sequence of characters.

Return true if this is possible, otherwise return false.

Input Format

  • An array of lowercase strings words.
  • Each string contains only letters a to z.

Output Format

  • Return a boolean indicating whether the strings can be made equal after redistributing characters.

Constraints

  • The number of strings is at least 1.
  • All strings contain only lowercase English letters.
  • The total number of characters is finite and fits in memory.
  • A valid redistribution must leave every string with the same length and the same characters.
Examples
Sample cases returned by the problem API.

Example 1

Input

words = ["abc","aabc","bc"]

Output

true

Explanation

Across all strings, the counts are: a=3, b=3, c=3. Since there are 3 strings, each character count is divisible by 3, so we can redistribute characters to make all strings equal to "abc".

Example 2

Input

words = ["ab","a"]

Output

false

Explanation

The total counts are a=2 and b=1. There are 2 strings, but b cannot be evenly distributed between them, so it is impossible to make both strings identical.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.