<p>Given a string <code>s</code>, rearrange the characters of <code>s</code> so that any two adjacent characters are not the same.</p>

<p>Return <em>any possible rearrangement of</em> <code>s</code> <em>or return</em> <code>&quot;&quot;</code> <em>if not possible</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "aab"
<strong>Output:</strong> "aba"
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "aaab"
<strong>Output:</strong> ""
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 500</code></li>
	<li><code>s</code> consists of lowercase English letters.</li>
</ul>

class Solution {
public:
    string reorganizeString(string s) {
        // max-heap
        // select the most char from large -> less
        vector<int> freq(26, 0);
        for(auto &c : s){
            freq[c - 'a']++;
        }

        priority_queue<pair<int, char>> pqs;
        for(int i = 0 ; i < 26 ; i++){
            if(freq[i] > 0){
                pqs.push({freq[i], (char) ('a' + i) });
            }
        }

        string res = "";
        pair<int, char> prev = {0, '#'};
        while(!pqs.empty()){
            pair<int, char> pq = pqs.top();
            pqs.pop();

            int count = pq.first;
            char ch = pq.second;

            res += ch;

            if(prev.first > 0){
                pqs.push(prev);
            }
            prev = {count-1, ch};
        }

        if(res.size() == s.size()){
            return res;
        }
        return "";
    }
};  
8600