Python, 100% faster
\nOkay, the concept is so:\n- we are trying to construct the string with "ababab...abbabbabb..." (assuming that giveb count of "a" is smaller that given count o
![image](https://assets.leetcode.com/users/images/653ede0d-61d9-4f19-92c7-3fa63fee8b4a_1611374878.0229938.png)\nOkay, the concept is so:\n- we are trying to construct the string with "ababab...abbabbabb..." (assuming that giveb count of "a" is smaller that given count of "b", if not just excahnge them)\n- to do so, we need (say) m number of "ab" pairs and (say) n number of "abb" triples. It means that count of "a" is m+n, count of "b" is m+2n. Rearranging gives m=2*count(a)-count(b); n=count(b)-count(a)\n- but what if 2*count(a)<count(b), then m is negative. No worries, we just add all exceeding "b" at the begining of the string to make somesing like "bbabab...abbabb..."\n- by pigeonhole count(b)<2*count(a)+3, otherwise such S would not exist\n- now, lets proceed with the code:\n\n```\nclass Solution(object):\n    def strWithout3a3b(self, a, b):\n        """\n        :type a: int\n        :type b: int\n        :rtype: str\n        """\n        ans=\'\'\n\t\t#first define which letter has larger count\n        if a>b:\n            l=a #larger count\n            s=b #smaller count\n            lt=\'a\' #letter with larger count\n            st=\'b\' #letter with smaller count\n        else: #same but opposite example\n            l=b\n            s=a\n            lt=\'b\'\n            st=\'a\'\n        if l>2*s: #adding exceed "b" to the begining\n            ans+=lt*(l-2*s)\n            l=s*2 #after addition count(b)=2*count(a) exactly\n        ans+=(st+lt)*(2*s-l)+(st+lt+lt)*(l-s) #just in accordance with the rearengement we did\n        return ans\n\t\t\n
[]