Simple iterative Python solution, beats more than 60%
Intuition\n-We need to produce solution with length of a+b\n-We need to favorize the letter that has a greater value\n\n# Approach\n-Iterate while a and b are n
# Intuition\n-We need to produce solution with length of a+b\n-We need to favorize the letter that has a greater value\n\n# Approach\n-Iterate while a and b are not used, use list to keep track of letters\n-If last two added letters are the same, add the opposite letter\n\n# Complexity\n- Time complexity: O(a+b)\n\n\n- Space complexity:\nO(a+b)\n\n# Code\n```python3 []\nclass Solution:\n    def strWithout3a3b(self, a: int, b: int) -> str:\n        # length = a + b\n        # num of a \'a\' letters\n        # num of b \'b\' letters\n        # subsctring aaa and bbb is not occuring in res\n        \n        res = []\n        while a > 0 or b > 0:\n            if len(res) >= 2 and res[-1] == res[-2]:  # Check last two characters\n                if res[-1] == \'a\':  # Last two characters are \'a\'\n                    res.append(\'b\')\n                    b -= 1\n                else:  # Last two characters are \'b\'\n                    res.append(\'a\')\n                    a -= 1\n            else:\n                # Prefer adding the letter with the higher count\n                if a >= b:\n                    res.append(\'a\')\n                    a -= 1\n                else:\n                    res.append(\'b\')\n                    b -= 1\n        \n        return "".join(res)\n```
['String', 'Python3']