FastPrepFastPrep
Problem Brief

Convert to Good String

OA
See Amazon online assessment and hiring insights

Given A String Containing Integers, A Good String Is One Not Containing A Subsequence With The Patterns "010" Or "101". You Can Perform Operations To Convert 0 To 1 Or 1 To 0. Return The Number Of Operations Required To Convert A Given String To A Good String

1Example 1

Input
s = "111101110100"
Output
2
Explanation
We convert the 0s to 1s in Position 5 andnd 9 - "1111111111100"
public int convertToGoodString(String s) {
  // write your code here
}
Input

s

"111101110100"

Output

2

Sign in to submit your solution.