You are given a binary string s and an integer k.
Your task is to determine whether every possible binary code of length k appears as a substring in s.
Return:
true if all possible binary codes of size k exist as substrings of s,
otherwise, return false.
Input: s = "0110" k = 1
Output: true
Explanation:
All binary codes of length 1 → "0", "1" Both exist in the string, so true.
Input: s = "00110110" k = 2
Output: true
Explanation:
All binary codes of length 2 are: "00" → found at index 0 "01" → found at index 1 "10" → found at index 3 "11" → found at index 2 Since all are present, return true.
Input: s = "0110" k = 2
Output: false
Explanation:
Binary codes of length 2 are "00", "01", "10", "11". The substring "00" does not appear → false.
Accepted:
Submission: