2dbi

Maximum Palindromic Strings via Cross-String Letter Swaps

viaLeetCode

Given an array of n lowercase strings, in one operation you may swap any two letters from any two distinct strings. Determine the maximum number of strings that can be made palindromes after any number of such swaps. Count total frequency of each letter across all strings; a string of length L can be a palindrome if it has at most one odd-count character (or L is odd), so greedily pair letters across strings to satisfy as many strings as possible.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account