<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<vector<int>> freq (26,vector<int>(2,0));
        for(int i=0;i<s.size();i++) freq[s[i]-'a'][0]++, freq[s[i]-'a'][1] = s[i]-'a';
        int pointer = 0;
        sort(freq.begin(), freq.end());
        for(int i=freq.size()-1;i>=0;i--){
            for(int j = 0; j<freq[i][0]; j++){
                s[pointer] = (char)(freq[i][1] + 'a');
                pointer+=2;
                if(pointer>=s.size()) pointer = 1;
            }
        }
        for(int i=1;i<s.size();i++){
            if(s[i]==s[i-1]) return "";
        }
        return s;
    }
};
7800