<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) {
    map<char , int> m1;
	
	for(char i:s){
		m1[i]++;
	}
	int maxi =INT_MIN;
	char maxChar;
	for(auto i:m1){
		if(i.second>maxi){
			maxi=i.second;
			maxChar=i.first;
		}
	}
	int n=s.length();
	if((n%2==0 && maxi>n/2) ||(n%2 && maxi>n/2+1))return "";
	int pos=0;
	while(maxi--){
        s[pos]=maxChar;
        m1[maxChar]--;
        pos+=2;
    }
    for(auto i:m1){
        while(i.second!=0){
            if(pos>=n)pos=1;
            s[pos]=i.first;
            pos+=2;
            i.second--;
        }
    }
    return s;
        
    }
};
9000