<p>Given a string <code>s</code> which consists of lowercase or uppercase letters, return the length of the <strong>longest <span data-keyword="palindrome-string">palindrome</span></strong>&nbsp;that can be built with those letters.</p>

<p>Letters are <strong>case sensitive</strong>, for example, <code>&quot;Aa&quot;</code> is not considered a palindrome.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abccccdd&quot;
<strong>Output:</strong> 7
<strong>Explanation:</strong> One longest palindrome that can be built is &quot;dccaccd&quot;, whose length is 7.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;a&quot;
<strong>Output:</strong> 1
<strong>Explanation:</strong> The longest palindrome that can be built is &quot;a&quot;, whose length is 1.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 2000</code></li>
	<li><code>s</code> consists of lowercase <strong>and/or</strong> uppercase English&nbsp;letters only.</li>
</ul>

class Solution {
public:
std::map<char, int> alpha = {{'a', 1}, 
                                    {'b', 2},
                                    {'c', 3},
                                    {'d', 4},
                                    {'e', 5},
                                    {'f', 6},
                                    {'g', 7},
                                    {'h', 8},
                                    {'i', 9},
                                    {'j', 10},
                                    {'k', 11},
                                    {'l', 12},
                                    {'m', 13},
                                    {'n', 14},
                                    {'o', 15},
                                    {'p', 16},
                                    {'q', 17},
                                    {'r', 18},
                                    {'s', 19},
                                    {'t', 20},
                                    {'u', 21},
                                    {'v', 22},
                                    {'w', 23},
                                    {'x', 24},
                                    {'y', 25},
                                    {'z', 26}, 
                                    {'A', 27}, 
                                    {'B', 28},
                                    {'C', 29},
                                    {'D', 30},
                                    {'E', 31},
                                    {'F', 32},
                                    {'G', 33},
                                    {'H', 34},
                                    {'I', 35},
                                    {'J', 36},
                                    {'K', 37},
                                    {'L', 38},
                                    {'M', 39},
                                    {'N', 40},
                                    {'O', 41},
                                    {'P', 42},
                                    {'Q', 43},
                                    {'R', 44},
                                    {'S', 45},
                                    {'T', 46},
                                    {'U', 47},
                                    {'V', 48},
                                    {'W', 49},
                                    {'X', 50},
                                    {'Y', 51},
                                    {'Z', 52}
};
    int longestPalindrome(string s) {
    if (s.size() == 0) return 0; 
    if (s.size() == 1) return 1;
    
    int size = 0; 
    
    std::vector<int> num(alpha.size(), 0); 
    
    for (int i = 0; i < s.size(); i++)
    {
        int index = alpha.find(s[i])->second; 
        num[index]++; 
    }
    
    for (int i = 0; i < num.size(); i++)
    {
        while (num[i] >= 2)
        {
            size = size + 2; 
            num[i] = num[i] - 2; 
        }
    }
    
    for (int i = 0; i < num.size(); i++)
    {
       if (num[i] == 1)
        {
            size++; 
            num[i]--; 
            break; 
        }
    }
    
    return size; 
    }
};
8700