100% Beats Java Solution , Bitwise Approach to Maximize Palindrome Length in Linear Time🔥.
Intuition\nUse a bitmask to track character frequencies. Each character toggles a specific bit; 1 means odd frequency, 0 means even. Count the 1s to get the odd
# Intuition\nUse a bitmask to **track character frequencies**. Each character toggles a specific bit; 1 means odd frequency, 0 means even. Count the 1s to get the odd-frequency characters. Max palindrome length is **n - (odd_count - 1).**\n\n# Complexity\n- Time complexity: **O(n)**\n\n- Space complexity: **O(1)**\n\n# Code\n```java []\nclass Solution {\n    public int longestPalindrome(String str) {\n        long bit=0L;\n        int n=str.length();\n        for(int i=0;i<n;i++) bit^=(1L<<(str.charAt(i)-\'A\')); \n        bit=Long.bitCount(bit);\n        return n-(int)(bit==0?0:bit-1);\n    }\n}\n```
['Bit Manipulation', 'Bitmask', 'Java']