← 返回 amazon 的题目列表Find Minimum Operations to Transform Image into Its Reverse
类型:online_judge
A company stores grayscale images as binary strings, where '1' represents a white pixel and '0' represents a black pixel. The reverse of an image is simply the binary string read backward. To create a backup, you are allowed to perform the following operation any number of times: remove any character from the string and append it to the end. Given a binary string image, determine the minimum number of operations required to transform it into its reverse.
Example 1:
Input: image = "0100110"
Output: 3
Explanation:
"0100110" => "0101100" => "0011001" => "0110010"
Move the "0" at index 3 to the end: "0100110" → "0101100"
Move the "1" at index 1 to the end: "0101100" → "0011001"
Move the "0" at index 1 to the end: "0011001" → "0110010"
Example
Input
0100110