Menu

Hackerrank > Algorithms > Strings > Beautiful Binary String

January 7, 2017 - Hackerrank

Language: Python

import sys


n = int(raw_input().strip())
B = map(int, list(raw_input().strip()))

count=0
for i in xrange(2,n):
    if B[i-2]==0 and B[i-1]==1 and B[i]==0:
        B[i]=1
        count+=1
print count

(164)

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VK

Author of this post : Unknown Author

Leave a Reply

Your email address will not be published. Required fields are marked *