diff --git a/check-if-a-string-contains-all-binary-codes-of-size-k/sol.rs b/check-if-a-string-contains-all-binary-codes-of-size-k/sol.rs new file mode 100644 index 0000000..59e969c --- /dev/null +++ b/check-if-a-string-contains-all-binary-codes-of-size-k/sol.rs @@ -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::>() + .len() == 1 << k + } +} \ No newline at end of file