Leetcode 1065 Solution

This article provides solution to leetcode question 1065 (binary-string-with-substrings-representing-1-to-n)

https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n

Solution

class Solution:
    def queryString(self, S: str, N: int) -> bool:
        for i in range(1, N + 1):
            if "{0:b}".format(i) not in S:
                return False
        return True