Java simple recursive solution 4ms beats 99.80% + explanation
The idea is simple:\n1. find max(A,B), and so define MORE and LESS variables\n2. every step we want to decrease the difference MORE-LESS to avoid the case when 
The idea is simple:\n1. find max(A,B), and so define MORE and LESS variables\n2. every step we want to decrease the difference MORE-LESS to avoid the case when in the end of the string we have too much same letters. So at the end of algorithm this difference should bw at most = 2.\n3. each letter can repeat contiguonaly at max 2 times -> if we know, that the difference MORE-LESS>2, we write 2 letters responsible for MORE and 1 for LESS number to decrease the difference. !!!WE DON\'T WRITE ONLY "MORE" LETTERS WITHOUT "LESS" LETTERS BECAUSE IF ON THE NEXT ITERATION MORE-LESS>2 AGAIN, WE\'LL HAVE TOO MUCH CONTIGUOUS "MORE" LETTERS (>3).\n4. when MORE-LESS is finally 2 or less, we keep calm and append every letter only once.\n\nThe full code:\n```\nclass Solution {\n    public String strWithout3a3b(int A, int B) {\n        StringBuilder b = new StringBuilder();\n        if (A<B){\n            createString(b, A, B, \'a\', \'b\');\n        }else {\n             createString(b, B, A, \'b\', \'a\');\n        }\n        return b.toString();\n    }\n    \n    public void createString (StringBuilder b, int less, int more, char l, char m){\n        if (more==0) return;\n        else if (less==0) {\n            b.append(m);\n            createString(b,less,more-1,l,m);\n        }\n        else if (more-less>=3){\n            b.append(m).append(m).append(l);\n            createString(b,less-1,more-2,l,m);\n        }\n        else {\n            b.append(m).append(l);\n            createString(b,less-1,more-1,l,m);\n             }\n    }\n}\n```
[]