var longestPalindrome = function(s) {
let trackkerObject = new Map();
let n = 0;
for (let i = 0; i < s.length; i++) {
if (trackkerObject.has(s[i])) {
n += 2;
trackkerObject.delete(s[i]);
} else {
trackkerObject.set(s[i], i);
}
}
return trackkerObject.size > 0 ? n+1 : n;
};
console.log(longestPalindrome("abccccdd"));
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)