O(n) Time Complexity Java Solution with Algo | HashMap
Algorithm\n Create a HashMap and add character if not present. If present then remove it from map.\n If there is no element left in map, then complete s can be 
**Algorithm**\n* Create a HashMap and add character if not present. If present then remove it from map.\n* If there is no element left in map, then complete s can be modified as a palindrome. So return length of s.\n* If there\'s some element left in map, then leaving one element which can be in centre of palindrome number, rest all cannot be taken for making palindrome. So return, length of s - length of map + 1\n\nTime Complexity: O(n)\n\n**Code**\n```\npublic int longestPalindrome(String s) {\n        HashMap<Character, Integer> map = new HashMap();\n        for(int i=0; i<s.length(); i++){\n            char temp = s.charAt(i);\n            if(map.get(temp) != null) map.remove(temp);\n            else map.put(temp, i);\n        }\n        if(map.size() <= 1) return s.length();\n        return s.length() - map.size() + 1;\n    }\n```\n**Please upvote if it helped**\n*Feel free to ask any questions/query in comment section*
['Java']