Prefix Flip (Hard Version)
MediumRating 1700CodeforcesConstructive Algorithms
Approach hintTry it first, then revealHide
Flipping the prefix at every position where adjacent characters differ makes a string uniform in under n steps. Do this for a, fix the colour with one full flip if needed, then append the steps for b in reverse order.