Loop traversal to mark K adjacent positions to the right of already existing 1 s .
for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == '1' : NEW_LINE INDENT for j in range ( i , len ( s ) ) : NEW_LINE INDENT if ( j <= i + k ) : NEW_LINE INDENT ar [ j ] = - 1 NEW_LINE end = j NEW_LINE DEDENT DEDENT i = end NEW_LINE DEDENT DEDENT end = 0 NEW_LINE