FastPrepFastPrep
Problem Brief

Find Minimum Operations (It seems for FT in US but intern in CN)

NEW GRADINTERNOA
See Amazon online assessment and hiring insights

Amazon Web Services (AWS) manages grayscale images using sequences of black and white pixels. Each image is represented as a binary string where '1' indicates a white pixel, and '0' represents a black pixel. The reverse of an image is simply the binary string in reverse order. For example, reversing "11010" results in "01011."

To maintain backups, AWS plans to generate the reverse of each image. You can perform a specific operation any number of times to achieve this: select any character from the string, remove it, and append it to the end. This operation mimics shifting a pixel to the back of the string.

Your goal is to determine the minimum number of operations required to convert the original binary representation of the image into its reversed version.

1Example 1

Input
pixelString = "0100110"
Output
3
Explanation
Example 1 illustration

2Example 2

Input
pixelString = "00110101"
Output
3
Explanation
The string can be reversed in minimum 3 moves using the following sequence: 1. 00110101 -> 00101011 2. 00101011 -> 01010110 3. 01010110 -> 10101100

3Example 3

Input
pixelString = "101011"
Output
2
Explanation
The explanation is incomplete, so I did not include it.

Constraints

Limits and guarantees your solution can rely on.

1 <= pixelString.length() <= 10^5
public int findMinimumOperations(String pixelString) {
  // write your code here
}
Input

pixelString

"0100110"

Output

3

Sign in to submit your solution.