Algorithm · Salesforce · Medium
Consider a string made up entirely of the characters '0' and '1'. In a single instant, you may transform every adjacent "01" pair in the current string into "10" — that is, anywhere a zero is immediately followed by a one, they swap places simultaneously. This instant operation is performed repeatedly, always using the state of the string at the start of that instant. The task halts when no "01" substring remains. Compute the total number of instants required until the…
Checking your access…