Python short and readable solution (beats 99%)
Approach\nAdd \'a\' or \'b\' to the solution one character at a time. Favor the character with higher remaining frequency (being careful not to add three equal 
# Approach\nAdd _\'a\'_ or _\'b\'_ to the solution one character at a time. Favor the character with higher remaining frequency (being careful not to add three equal characters in a row).\n\n# Complexity\n- Time complexity: $$O(a + b)$$\n\n- Space complexity: $$O(1)$$ aside from the output itself\n\n# Code\n```\nclass Solution:\n    def strWithout3a3b(self, a: int, b: int) -> str:\n        res = []\n        a_in_a_row, b_in_a_row = 0, 0\n        for _ in range(a + b):\n            if (a > b and a_in_a_row < 2) or b_in_a_row == 2:\n                res.append(\'a\')\n                a_in_a_row, b_in_a_row = a_in_a_row + 1, 0\n                a -= 1\n            else:\n                res.append(\'b\')\n                a_in_a_row, b_in_a_row = 0, b_in_a_row + 1\n                b -= 1\n        return "".join(res)\n```
['Python3']