Problem · Dynamic Programming

Convert to Good String

Learn this problem
MediumAmazonOA
See Amazon hiring insights

Problem statement

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

Function

convertToGoodString(s: String) → int

Examples

Example 1

s = "111101110100"return = 2
We convert the 0s to 1s in Position 5 andnd 9 - "1111111111100"

More Amazon problems

drafts saved locally
public int convertToGoodString(String s) {
  // write your code here
}
s"111101110100"
expected2
checking account