Rearrange letters across multiple words to maximize how many words can be turned into palindromes.
You are given an array of words. In one operation, you may take a character from any word and place it into any other word, preserving the total multiset of characters across all words.
Your task is to determine the maximum number of words that can be rearranged into palindromes after any number of such operations.
A word can be rearranged into a palindrome if its characters can be permuted so that the word reads the same forward and backward.
words.Example 1
Input
words = ["abbb","ba","aa"]
Output
3
Explanation
By rearranging letters, all three words can become palindromes: "bbbb", "aa", and "aa". One possible way is to move letters between words so the total letters are redistributed to satisfy each length's palindrome requirement.
Example 2
Input
words = ["abc","def","gh"]
Output
1
Explanation
Only one word of length 3 can be made into a palindrome using the available letters; the length-2 word would need one matching pair, which is not available after best redistribution.
Premium problem context
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.