💯💯Easiest solution || 🔥🔥Without any Data Structure 🔥🔥|| Count Frequency || Easy to Understand
\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\n    public int longestPalindrome(String s) {\n        boole
\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n    public int longestPalindrome(String s) {\n        boolean[] arr = new boolean[123];   // a-z ASCII value is 65 to 90 && A-Z ASCII value is 97 to 122\n        int i = 0;\n        int ans = 0;\n        while(i<s.length()){\n            if(arr[(int)(s.charAt(i))]==false){    // odd time charactor occur & note down into the array\n                arr[(int)(s.charAt(i))] = true;    // note down into the array\n            }else{\n                arr[(int)(s.charAt(i))] = false;    //even time charactor occur & ans+=2\n                ans+=2;\n            }\n            i++;\n        }\n\n        //after while loop if any odd occur reamining then longest palindrome is ans+1\n        for(i = 65; i<arr.length ; i++){\n            if(arr[i])return ans+1;\n        }\n\n        //otherwise longest palindrome is ans\n        return ans;\n    }\n}\n```
['Java']