leetcode 1016. Binary String With Substrings Representing 1 To N

Posted 周洋的Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 1016. Binary String With Substrings Representing 1 To N相关的知识,希望对你有一定的参考价值。

暴力就可以过,因为S最大1000,2的10次方就1024,后面的其实都不行.

class Solution(object):
    def queryString(self, S, N):
        if N>1024:return False
        return all(bin(i)[2:] in S for i in xrange(N,0, -1))
        

 

以上是关于leetcode 1016. Binary String With Substrings Representing 1 To N的主要内容,如果未能解决你的问题,请参考以下文章

leetcode67. Add Binary

14.leetcode67_add_binary

Leetcode 696. Count Binary Substrings

LeetCode297. Serialize and Deserialize Binary Tree

257. Binary Tree Paths

LeetCode 236. Lowest Common Ancestor of a Binary Tree(浜屽弶鏍戞眰涓ょ偣LCA)