← ALL NOTES
Hash Table

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

Check whether s contains every binary code of length k (all 2\^k of them) as a substring. A bit-based rolling window lets you enumerate all length-k substrings in O(n) and mark which codes appear.

Loading…