aa tiles "AA", bb tiles "BB" and ab tiles "AB". Tiles are laid out in a row in any order and cannot be flipped. You may use any subset of them, from all to none.
The resulting string must not contain three equal letters in a row ("AAA" or "BBB"). Return the maximum possible length of the string.aa=1, bb=1, ab=1 → 6
All three tiles fit: "AB" + "AA" + "BB" = "ABAABB", length 6, with no three equal letters in a row.
aa=4, bb=1, ab=2 → 10
"AA" tiles must alternate with "BB", and there is only one "BB", so at most two "AA" fit. For example "AB" + "AB" + "AA" + "BB" + "AA" = "ABABAABBAA", length 10.
aa=3, bb=3, ab=5 → 22
aa=1, bb=1, ab=1
6
Run checks the first 3 tests in your browser. Submit checks all 88 tests on the server, hidden ones included.