Construct the Longest New String
Choose AA, BB and AB blocks without AAA or BBB; a DP over used counts tracks how the string ends so each block is placed legally.
Choose AA, BB and AB blocks without AAA or BBB; a DP over used counts tracks how the string ends so each block is placed legally.