class Solution {
public boolean hasAllCodes(String s, int k) {
if (s.length() < ( (1 << k) + k - 1)){
return false;
}
Set<String> set = new HashSet<>();
for (int i = 0; i <= s.length() - k; i++){
set.add(s.substring(i, k + i));
}
return set.size() == ( 1 << k);
}
}