<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) {
        vector<int> myvec(26,0);
        priority_queue<vector<int>> pq;
        string result(s);
        int interval = 0;

        for(auto& entry: s)
            myvec[entry-'a']++;

        for(int i=0;i<myvec.size();i++) {
            if(myvec[i] !=0)
                pq.push({myvec[i], i +'a'});
        }
    vector<int> resVec = pq.top();
    if(resVec[0] > ((s.size()+1)/2))
        return "";
    while(!pq.empty())
        {
            for(int i=interval; i < result.size();i = i+2) {
                result[i] = char(resVec[1]);
                if (--resVec[0] == 0) {
                    pq.pop();
                    if(!pq.empty())
                        resVec = pq.top();
                }
            }
            interval=1;
        }
        return result;
    }
};
8300