Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **Beautiful Binary String**
- Alice has a binary string, B, of length n. She thinks a binary string is beautiful if and only if it doesn't contain the substring “010”.
- In one step, Alice can change a 0 to a 1 (or vice-versa). Count and print the minimum number of steps needed to make Alice see the string as beautiful.
- Input Format
- The first line contains an integer, n (the length of binary string B).
- The second line contains a single binary string, B, of length .
- Constraint*
- 1 <= n <= 100
- Each character in B E {0, 1}.
- Output Format
- Print the minimum number of steps needed to make the string beautiful.
- Sample Input 0
- 7
- 0101010
- Sample Output 0
- 2
- Sample Input 1
- 5
- 01100
- Sample Output 1
- 0
- Sample Input 2
- 10
- 0100101010
- Sample Output 2
- 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement