Search
⌘K

Leetcode 1461. Check If a String Contains All Binary Codes of Size K

Determine whether a binary string s contains every possible binary substring of length k (i.e., all 2^k distinct codes). With k ≤ 20 and |s| ≤ 5e5, this is typically solved by scanning k-length windows (e.g., using a rolling bitmask/set) to collect distinct substrings and checking if their count equals 2^k.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.