check-if-a-string-contains-all-binary-codes-of-size-k
This commit is contained in:
parent
2fc684641f
commit
5a1d509d09
|
@ -0,0 +1,10 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
impl Solution {
|
||||||
|
pub fn has_all_codes(s: String, k: i32) -> bool {
|
||||||
|
s.into_bytes()
|
||||||
|
.windows(k as usize)
|
||||||
|
.collect::<HashSet<_>>()
|
||||||
|
.len() == 1 << k
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue