Construct a K | Function to construct binary string according to the given conditions ; Initialize with 1 ; Traverse the array ; To check if the i - th eger needs to be considered or not ; Print the binary string for i in range ( 1 , K ) : print ( bit [ i ] ) ; Given array ; Size of the array ; Given K
def constructBinaryString ( arr , N , K ) : NEW_LINE INDENT bit = 1 NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT bit |= bit << arr [ i ] NEW_LINE DEDENT bit = bin ( bit ) . replace ( "0b " , " " ) NEW_LINE print ( bit [ 1 : K + 1 ] ) NEW_LINE DEDENT arr = [ 1 , 6 , 1 ] NEW_LINE N = len ( arr ) NEW_LINE K = 8 NEW_LINE constructBinaryString ( arr , N , K ) NEW_LINE