Your question is Alternating Characters Variant. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A GSK laboratory sequence-validation step receives a string containing only A and B labels. Remove the minimum number of characters so that the remaining labels alternate, meaning no two adjacent retained characters are equal. Return both the minimum deletion count and one resulting alternating string. If both possible starting patterns require the same number of deletions, return the lexicographically smaller result.
Characters may be removed but the order of all retained characters must remain unchanged.
Implement minimum_deletions_to_alternate(s), where s is a non-empty string containing only A and B. Return a two-element list [deletions, result], where deletions is an integer and result is the retained alternating string.
def minimum_deletions_to_alternate(s):