Beats 100% C++
Code

![image.png](https://assets.leetcode.com/users/images/72c1968b-53f5-4d74-8fe8-63f99d329b03_1735918406.5700467.png)


# Code
```cpp []
class Solution {
public:
    string strWithout3a3b(int a, int b) {
        string s{" "};
        int balance = 0;
        char ch;
        while (a+b>0)
        {
            if (b>0 && (a == 0 || b>a && balance < 2 || balance == -2))
            {
                ch = 'b';
                --b;
                if (s.back() == ch)
                    ++balance;
                else
                    balance = 1;
            }
            else if (a>0 && (b == 0 || balance >-2 || balance == 2))
            {
                ch = 'a';
                --a;
                if (s.back() == ch)
                    --balance;
                else
                    balance = -1;
            }
            s += ch;
        }
        s.erase(0,1);
        return s;
    }
};
```
['String', 'C++']