LeetCode 1461, Medium. Topics: Hash Table, String, Bit Manipulation, Rolling Hash, Hash Function, Directed Acyclic Graph. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 25 parametrized pytest cases, and a playground notebook:
Problem
Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.
Examples
Constraints
1 <= s.length <= 5 * 10^5
s[i] is either '0' or '1'.
1 <= k <= 20
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026