- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1461.java
19 lines (17 loc) · 602 Bytes
/
_1461.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
packagecom.fishercoder.solutions.secondthousand;
importjava.util.HashSet;
importjava.util.Set;
publicclass_1461 {
publicstaticclassSolution1 {
/*
* inspired by https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k/discuss/660505/Java-4-lines-solution
*/
publicbooleanhasAllCodes(Strings, intk) {
Set<String> set = newHashSet<>();
for (inti = 0; i <= s.length() - k; i++) {
set.add(s.substring(i, i + k));
}
returnset.size() == 1 << k;
}
}
}