Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. **Beautiful Binary String**
  2. 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”.
  3. 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.
  4. Input Format
  5. The first line contains an integer, n (the length of binary string B).
  6. The second line contains a single binary string, B, of length .
  7. Constraint*
  8. 1 <= n <= 100
  9. Each character in B E {0, 1}.
  10. Output Format
  11. Print the minimum number of steps needed to make the string beautiful.
  12. Sample Input 0
  13. 7
  14. 0101010
  15.  
  16.  
  17. Sample Output 0
  18. 2
  19.  
  20.  
  21. Sample Input 1
  22. 5
  23. 01100
  24.  
  25.  
  26. Sample Output 1
  27. 0
  28.  
  29.  
  30. Sample Input 2
  31. 10
  32. 0100101010
  33.  
  34.  
  35. Sample Output 2
  36. 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement