Question: Python solution to the following algorithm question: 'Query String': Give a binary string str and an integer n to check if the substring of the

Python solution to the following algorithm question: 'Query String':

Give a binary string str and an integer n to check if the substring of the string contains all binary representations of non-negative integers less than or equal to the given integer.

String length does not exceed 100,000 n does not exceed 100,000 Binary starts at 0 and does not require leading zeros

Description

Give a binary string str and an integer n to check if the substring of the string contains all binary representations of non-negative integers less than or equal to the given integer.

String length does not exceed 100,000 n does not exceed 100,000 Binary starts at 0 and does not require leading zeros

Have you met this question in a real interview? Yes

Problem Correction

Example

Given str="0110",n=3, return yes.

The substring of str contains "0", "1", "10", "11". 

Given str="0110",n=4, return no.

The substring of str does not contain "100"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!