My Java Solution with the basic idea as comments
\nclass Solution {\n    public String strWithout3a3b(int a, int b) {\n        StringBuilder sb = new StringBuilder();\n        while (a > 0 || b > 0) {\n       
```\nclass Solution {\n    public String strWithout3a3b(int a, int b) {\n        StringBuilder sb = new StringBuilder();\n        while (a > 0 || b > 0) {\n            String s = sb.toString();\n            // if we have aa as the last 2 characters, then the next one is b\n            if (s.endsWith("aa")) {\n                sb.append("b");\n                b --;\n            }\n            // if we have bb as the last 2 characters, then the next one is a\n            else if (s.endsWith("bb")) {\n                sb.append("a");\n                a --;\n            }\n            // if a > b, append a\n            else if (a > b) {\n                sb.append("a");\n                a --;\n            }\n            // if b >= a, append b\n            else {\n                sb.append("b");\n                b --;\n            }\n        }\n        return sb.toString();\n    }\n}\n```
['String', 'Java']