JavaScript simple hashmap O(n) solution
```\nvar longestPalindrome = function(s) {\n    var map = {};\n    var result = 0;\n    for(let i = 0; i < s.length; i++){\n        if(map[s[i]] === undefined){
```\nvar longestPalindrome = function(s) {\n    var map = {};\n    var result = 0;\n    for(let i = 0; i < s.length; i++){\n        if(map[s[i]] === undefined){\n            map[s[i]] = 1;\n        }\n        else if(map[s[i]] === 1){\n            map[s[i]] = undefined;\n            result += 2;\n        }\n    }\n    if(s.length > result){\n        result += 1;\n    }\n    return result;\n};
[]