Skip to content

Commit b7201c8

Browse files
Merge pull request #2583 from leahjia/1461-check-if-a-string-contains-all-binary-codes-of-size-k.java
Create 1461-check-if-a-string-contains-all-binary-codes-of-size-k.java
2 parents 2421f29 + 646a190 commit b7201c8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution {
2+
public boolean hasAllCodes(String s, int k) {
3+
Set<String> set = new HashSet<>();
4+
for (int i = 0; i <= s.length() - k; i++) {
5+
set.add(s.substring(i, i + k));
6+
}
7+
return set.size() == Math.pow(2, k);
8+
}
9+
}

0 commit comments

Comments
 (0)