构造二进制字符串

目录

LeetCode3221 生成不含相邻零的二进制字符串


#include <iostream>
#include <vector>
using namespace std;

void dfs(string s,int n,vector<string>& res){
    if(s.size()==n){
        res.push_back(s);
        return;
    }
    dfs(s+"0",n,res);
    dfs(s+"1",n,res);
}

int main(){
    int n;
    cin>>n;
    vector<string> res;
    dfs("",n,res);
    for(int i=0;i<res.size();i++) cout<<res[i]<<endl;
    return 0;
}

LeetCode3221 生成不含相邻零的二进制字符串

相关推荐

  1. 【Golang】补码二进制字符串转整型

    2024-07-09 20:06:08       50 阅读
  2. rust - 动态构造文件名字符串

    2024-07-09 20:06:08       41 阅读
  3. 每日OJ题_字符串③_力扣67. 二进制求和

    2024-07-09 20:06:08       37 阅读
  4. Leetcode-1702-修改后的最大二进制字符串-c++

    2024-07-09 20:06:08       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 20:06:08       53 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 20:06:08       56 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 20:06:08       46 阅读
  4. Python语言-面向对象

    2024-07-09 20:06:08       57 阅读

热门阅读

  1. npm证书过期问题

    2024-07-09 20:06:08       20 阅读
  2. GitHub使用教程(小白版)

    2024-07-09 20:06:08       16 阅读
  3. WebXR:Web上的虚拟与增强现实技术

    2024-07-09 20:06:08       28 阅读
  4. 如何在MATLAB中导入表格数据并进行运算?

    2024-07-09 20:06:08       24 阅读