package leetcode;

/**
 * https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/
 */
public class Problem1023 {
    public boolean queryString(String S, int N) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1023 prob = new Problem1023();
        System.out.println(prob.queryString("0110", 3)); // true
        System.out.println(prob.queryString("0110", 4)); // false
    }
}

package leetcode;

/**
 * https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/
 */
public class Problem1023 {
    public boolean queryString(String S, int N) {
        for (int i = N; i >= 1; i--) {
            String s = Integer.toBinaryString(i);
            if (!S.contains(s)) {
                return false;
            }
        }
        return true;
    }
}

Solve problem 1023