Algorithm · Amazon · Hard
A company archives grayscale images as binary strings: '1' denotes a white pixel and '0' denotes a black pixel. The mirror (reverse) of an image is the original string read from right to left. For backup purposes, you may apply the following move repeatedly: pick any character from the string, remove it, and place it at the very end. Given a binary string image, return the smallest number of moves needed to make image equal to its mirror. Example 1: Explanation: "010 0 110"…