C++ simple greedy beats 100%
cases:\n1. a == b: in that case "ababababa" or "babababa" will work depending upon the last character of our string.\n2.  a > b or b > a: We have to use up the 
**cases:**\n1. **a == b**: in that case "ababababa" or "babababa" will work depending upon the last character of our string.\n2.  **a > b or b > a**: We have to use up the larger one a bit fast so that they are not left behind without a break like after few steps if a >= 3 and b = 0 then we can not stop "aaa" from happening so we will always  add **2 of  the larger character and 1 of the smaller character**.      \nPlease upvote if ypu liked the answer it will motivate me to write better answers in the future. Thank You \n```\nclass Solution {\npublic:\n    string strWithout3a3b(int a, int b) {\n        string sol = "";\n        while(a && b)\n        {\n            if(a > b)\n            {\n                sol += "aab";\n                a -= 2;\n                b -= 1;\n            }\n            else if (b > a)\n            {\n                sol += "bba";\n                a -= 1;\n                b -= 2;\n            }\n            else if(a == b)\n            {\n                if( sol == "" || sol[sol.length() - 1] == \'a\')\n                {\n                    for(int i = 0; i < a; i++)\n                    {\n                        sol += "ba";\n                    }\n                    \n                }\n                else\n                {\n                    for(int i = 0; i < a; i++)\n                    {\n                        sol += "ab";\n                    }\n                }\n                a = 0;\n                b = 0;\n            }\n        }\n        if(a)\n        {\n            for(int i = 0; i < a; i++)\n            {\n                sol += \'a\';\n            }\n        }\n        if(b)\n        {\n            for(int i = 0; i < b; i++)\n            {\n                sol += \'b\';\n            }\n        }\n        return sol;\n        \n    }\n};\n```
[]