<p>A string <code>s</code> is called <strong>happy</strong> if it satisfies the following conditions:</p>

<ul>
	<li><code>s</code> only contains the letters <code>&#39;a&#39;</code>, <code>&#39;b&#39;</code>, and <code>&#39;c&#39;</code>.</li>
	<li><code>s</code> does not contain any of <code>&quot;aaa&quot;</code>, <code>&quot;bbb&quot;</code>, or <code>&quot;ccc&quot;</code> as a substring.</li>
	<li><code>s</code> contains <strong>at most</strong> <code>a</code> occurrences of the letter <code>&#39;a&#39;</code>.</li>
	<li><code>s</code> contains <strong>at most</strong> <code>b</code> occurrences of the letter <code>&#39;b&#39;</code>.</li>
	<li><code>s</code> contains <strong>at most</strong> <code>c</code> occurrences of the letter <code>&#39;c&#39;</code>.</li>
</ul>

<p>Given three integers <code>a</code>, <code>b</code>, and <code>c</code>, return <em>the <strong>longest possible happy </strong>string</em>. If there are multiple longest happy strings, return <em>any of them</em>. If there is no such string, return <em>the empty string </em><code>&quot;&quot;</code>.</p>

<p>A <strong>substring</strong> is a contiguous sequence of characters within a string.</p>

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

<pre>
<strong>Input:</strong> a = 1, b = 1, c = 7
<strong>Output:</strong> &quot;ccaccbcc&quot;
<strong>Explanation:</strong> &quot;ccbccacc&quot; would also be a correct answer.
</pre>

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

<pre>
<strong>Input:</strong> a = 7, b = 1, c = 0
<strong>Output:</strong> &quot;aabaa&quot;
<strong>Explanation:</strong> It is the only correct answer in this case.
</pre>

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

<ul>
	<li><code>0 &lt;= a, b, c &lt;= 100</code></li>
	<li><code>a + b + c &gt; 0</code></li>
</ul>

class Solution {
public:
    
    string longestDiverseString(int a, int b, int c) {
        stack<char> data;
        int currentSize=-1;
        char currentChar;
        if( a>=b && a>=c)  currentChar='a';
        else if(b>=a && b>=c) currentChar='b';
        else currentChar='c';
        // cout<<currentSize<<" "<<data.size()<<currentChar<<endl;
        while(currentSize !=data.size())
        {
            cout<<"In";
            currentSize= data.size();
           if(data.empty() ||  data.top()  !=currentChar  ) 
           {
                if(currentChar =='a' && a>=2 && a>=b && a>=c )
                {
                    data.push(currentChar);
                    data.push(currentChar);
                    a-=2;

                }
                else if(currentChar =='b' && b>=2 && b>=c && b>=a)
                {
                    data.push(currentChar);
                    data.push(currentChar);
                    b-=2;

                }
                else if(currentChar =='c' && c>=2 && c>=b && c>=a)
                {
                    data.push(currentChar);
                    data.push(currentChar);
                    c-=2;

                }
                else if (currentChar =='a' && a>=1)
                {
                   
                    data.push(currentChar);
                    a--;

                }
                else if(currentChar =='b' && b>=1)
                {
                    
                    data.push(currentChar);
                    b--;

                }
                else if(currentChar =='c' && c>=1)
                {
                 
                    data.push(currentChar);
                    c--;

                }

                if(currentChar=='a')
                {
                    if(b>c) currentChar='b';
                    else currentChar='c';
                }
                else if(currentChar =='b')
                {
                     if(a>c) currentChar='a';
                    else currentChar='c';
                }
                else
                {
                     if(a>b) currentChar='a';
                    else currentChar='b';
                }
           }

        }
        
        string out="";
        while(!data.empty())
        {
            out.push_back(data.top());
            data.pop();
        }
        reverse(out.begin(), out.end());
        return out;
        
    }
};
7600