Company: Coursera_16sep
Difficulty: medium
File Block Problem Description A software team is working on a data storage system where a file is represented as a binary string fileBlocks . A 1 represents a compressed file block and a 0 represents an uncompressed file block. The team wants to rearrange the blocks so that all compressed blocks (the 1 s) end up at the right end of the string. The string is rearranged by a sequence of operations. In a single operation: select any compressed block (a 1 ) that has an uncompressed block (a 0 ) immediately to its right, (inferred -- the source does not say so explicitly; a move of zero places would change nothing and would make the maximum cost unbounded, so every operation moves the block at least one place.) move it to the right until it reaches the end of the string or the position just before another compressed block. The block cannot stop earlier. (inferred -- the source says the block moves "until it reaches the end of the string or another compressed block"; every example in the so