Description
Submission
class Solution { public: string strWithout3a3b(int a, int b) { string ret; char ca = 'a', cb = 'b'; if(b > a) { swap(ca, cb); swap(a, b); } while(a || b) { if(b == 0) { while(a--) { ret.push_back(ca); } break; } if(a == 0) { while(b--) { ret.push_back(cb); } break; } if(a > b) { a -= 2; ret.push_back(ca); ret.push_back(ca); b -= 1; ret.push_back(cb); } else { ret.push_back(ca); ret.push_back(cb); --a; --b; } } return ret; } };