Company: Deutsche Bank IIT Guwahati_12feb
Difficulty: medium
Maximum Number of 3-Letter Palindromes Maximum Number of 3-Letter Palindromes Problem Description Given a string s , find the maximum number of 3-letter palindromes that can be formed using the letters from s . The rules are as follows: Each character from the original string s can be used at most once across all the formed palindromes. The letters from s can be rearranged to form the palindromes. Letters can be skipped if you do not want to use them. A 3-letter palindrome has the form XYX , where X and Y are characters. This means you need two of one character and one of another character to form one palindrome. Examples Example 1: Input: s = "aaaabc" Output: 2 Explanation: The available characters are four 'a's, one 'b', and one 'c'. We can form two 3-letter palindromes: 1. "aba" (uses two 'a's and one 'b') 2. "aca" (uses the remaining two 'a's and one 'c') All characters used are from the original string, and no character is used more than once. The maximum number of palindromes is