Problem · Dynamic Programming
Convert to Good String
Learn this problemProblem 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) → intExamples
Example 1
s = "111101110100"return = 2We convert the 0s to 1s in Position 5 andnd 9 -
"1111111111100"
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026