Back to problems

Binary String Synchronous '01' → '10' Replacement

Algorithm · Salesforce · Hard

Requirements You receive a binary string s containing n characters. At every second, replace each occurrence of "01" with "10" at the same time. Determine every pair to swap before changing the string; each identified pair is handled independently. Keep applying these rounds until the string no longer contains "01". Report how many rounds occurred. A direct simulation is suitable only for very small strings: an individual 1 can need to travel across numerous 0s, while other…

Checking your access…