3211. Generate Binary Strings Without Adjacent Zeros Medium
1/**
2 * [3211] Generate Binary Strings Without Adjacent Zeros
3 *
4 * You are given a positive integer n.
5 * A binary string x is valid if all <span data-keyword="substring-nonempty">substrings</span> of x of length 2 contain at least one "1".
6 * Return all valid strings with length n, in any order.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">n = 3</span>
11 * Output: <span class="example-io">["010","011","101","110","111"]</span>
12 * Explanation:
13 * The valid strings of length 3 are: "010", "011", "101", "110", and "111".
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">n = 1</span>
18 * Output: <span class="example-io">["0","1"]</span>
19 * Explanation:
20 * The valid strings of length 1 are: "0" and "1".
21 * </div>
22 *
23 * Constraints:
24 *
25 * 1 <= n <= 18
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/generate-binary-strings-without-adjacent-zeros/
31// discuss: https://leetcode.com/problems/generate-binary-strings-without-adjacent-zeros/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn valid_strings(n: i32) -> Vec<String> {
37 vec![]
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_3211() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.