human
Check if binary representations of 0 to N are present as substrings in given binary string | Function to convert decimal to binary representation.
Iterate over all bits of N.
If bit is 1.
Return binary representation.
Function to check if binary conversion of numbers from N to 1 exists in the string as a substring or not.
To store the count of number exists as a substring.
Traverse from N to 1.
If current number is not present in map.
Store current number.
Find binary of t.
If the string s is a substring of str.
Mark t as true.
Increment the count.
Update for t / 2.
Special judgment '0.
If the count is N + 1 , return " yes ".
Driver Code.
Given String.
Given Number.
Function Call"
Solution in Python:
assistant
#Here is code to check if binary representations of 0 to N are present as substrings in given binary string and the other steps required.
 def decimalToBinary ( N ) :
	ans = " "
	while ( N > 0 ) :
		if ( N & 1 ) :
			ans = '1' + ans
		else :
			ans = '0' + ans
		N //= 2
	return ans
def checkBinaryString ( str , N ) :
	map = [ 0 ] * ( N + 10 )
	cnt = 0
	for i in range ( N , - 1 , - 1 ) :
		if ( not map [ i ] ) :
			t = i
			s = decimalToBinary ( t )
			if ( s in str ) :
				while ( t and not map [ t ] ) :
					map [ t ] = 1
					cnt += 1
					t >>= 1
'
	for i in range ( len ( str ) ) :
		if ( str [ i ] == '0' ) :
			cnt += 1
			break
	if ( cnt == N + 1 ) :
		return " True "
	else :
		return " False "
if __name__ == ' _ _ main _ _ ' :
	str = "0110"
	N = 3
	print ( checkBinaryString ( str , N ) )