JAVA most straightforward and concise solution with detailed explanation!!!
\nclass Solution {\n    StringBuilder buffer = new StringBuilder();\n    public String strWithout3a3b(int A, int B) {\n        \n        // swap A and B,  so th
```\nclass Solution {\n    StringBuilder buffer = new StringBuilder();\n    public String strWithout3a3b(int A, int B) {\n        \n        // swap A and B,  so that A represents the greater number of occurance between A and B, a represents that corresponding letter.\n        String a = "a";\n        String b = "b";\n        if (B > A) {\n            int temp = B;\n            B = A;\n            A = temp;\n            a = "b";\n            b = "a";\n        }\n        String end = "";\n\t\t\n        // A > 2 * B + 2 there is no solution, when A = 2 * B + 2 means the end must have two consectutive As.\n\t\t// for consistency of code, we just add two \'a\'s to the end in advance. \n\t\t// So that we just need to deal with the case when A <= 2 * B,where we can handle these case by keep adding two patterns \'ab\' and \'aab\'.\n        if (A > 2 * B) {\n            end = a + a;\n            A -= 2;\n        }else {\n            end = "";\n        }\n\n        //  diminish the gap between A and B until A == B\n         while (A != B) {\n            if (A > B) {\n                buffer.append(a + a + b);\n                A -= 2;\n                B -= 1;\n            }\n        }\n       \n        // on this stage, A = B, so we just add  pattern \'ab\'\n        while (A > 0) {\n            buffer.append(a + b);\n            A--;\n            B--;\n        }\n        // add the end;\n        buffer.append(end);\n        return buffer.toString();\n    }\n    \n}\n```
[]