Given two integers a and b, return any string s such that:


	s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters,
	The substring 'aaa' does not occur in s, and
	The substring 'bbb' does not occur in s.


&nbsp;
Example 1:

Input: a = 1, b = 2
Output: "abb"
Explanation: "abb", "bab" and "bba" are all correct answers.


Example 2:

Input: a = 4, b = 1
Output: "aabaa"


&nbsp;
Constraints:


	0 &lt;= a, b &lt;= 100
	It is guaranteed such an s exists for the given a and b.


class Solution:
    def strWithout3a3b(self, a: int, b: int) -> str:
        if a<3 and b<3:
            return 'a'*a+'b'*b
        s=''
        if a>=b:
            k=a//b
            
            if a//b!=a/b:
              
                k+=1
            if k>=3:
                k=2
            while a>0 or b>0:
               
                if a>k:
                    s+='a'*k  
                else:
                    s+='a'*a
                a-=k
                if b>0:
                    s+='b'
                b-=1
                if a==b:
                    k=1
        if a<b:
            k=b//a
            if b//a!=b/a:
               
                k+=1
            if k>=3:
                k=2
            while b>0 or a>0:
                
                if b>k:
                    s+='b'*k  
                else:
                    s+='b'*b
                b-=k
                if a>0:
                    s+='a'
                a-=1
                if a==b:
                    k=1
        return s
class Solution {
    public String strWithout3a3b(int a, int b) {
        StringBuilder sb = new StringBuilder();
        int x = Math.min(a, Math.min(b, Math.abs(a - b))); // TAKE THE MIN OF (a, b, abs(a - b))
        if (a > b){
            sb.append("aab".repeat(x));
            b -= x;
            a -= 2 * x;
        }
        if (a < b){
            sb.append("bba".repeat(x));
            b -= 2 * x;
            a -= x;
        }
        if (a == b){
            sb.append("ab".repeat(a));
        }
        if (a == 0){
            sb.append("b".repeat(b));
        }
        if (b == 0){
            sb.append("a".repeat(a));
        }
        return sb.toString();
    }
}
class Solution {
public:
    string strWithout3a3b(int a, int b) {
        string ans="";
        while(a and b){
            if(a > b) ans += "aab", a--;
            else if(b > a) ans +="bba", b--;
            else ans += "ab";
            a--, b--;
        }
        while(a) ans +='a' , a--;
        while(b) ans +='b' , b--;
        return ans;
    }
};
/**
 * @param {number} a
 * @param {number} b
 * @return {string}
 */
var strWithout3a3b = function(a, b) {
    let r = '';

    let A = 'a', AA = A + A;
    let B = 'b', BB = B + B;

    while (a > 0 || b > 0) {
        if (a > b) {
            a = calculate(a, A, AA);
            b = calculate(b, B, BB, true);
        }
        else {
            b = calculate(b, B, BB);
            a = calculate(a, A, AA, true);
        }
    }

    return r;

    function calculate(v, s, ss, l = false) {
        if (l) {
            if (v > 0) {
                r += s, v -= 1;
            }

            return v;
        }

        let c = v >= 2 && r[r.length - 1] !== s;

        r += c ? ss : s;
        v -= c ? 2 : 1;

        return v;
    }
};
String Without AAA or BBB