当前位置: 首页 > news >正文

一个网站建设需要多少人力手机百度搜索引擎

一个网站建设需要多少人力,手机百度搜索引擎,挖金矿游戏网站建设,博物馆展柜给你一个正整数 n。 如果一个二进制字符串 x 的所有长度为 2 的 子字符串 中包含 至少 一个 "1",则称 x 是一个 有效 字符串。 返回所有长度为 n 的 有效 字符串,可以以任意顺序排列。 示例 1: 输入: n 3 输出&a…

给你一个正整数 n

如果一个二进制字符串 x 的所有长度为 2 的

子字符串

中包含 至少 一个 "1",则称 x 是一个 有效 字符串。

返回所有长度为 n 的 有效 字符串,可以以任意顺序排列。

示例 1:

输入: n = 3

输出: ["010","011","101","110","111"]

解释:

长度为 3 的有效字符串有:"010""011""101""110" 和 "111"

示例 2:

输入: n = 1

输出: ["0","1"]

解释:

长度为 1 的有效字符串有:"0" 和 "1"

思路

  • 如果我们有长度为 x 的字符串,根据二进制的规则,我们就能够生成长度为 x+1 的字符串(递归调用)
  • 如果当前字符串以 0 结尾,我们只能向后补 1,否则出现 00,如果以 1 结尾,则可以补 0 或 1。

因此我们可以采用递归的思想,从长度为 1 的字符串开始生成,按照上面的逻辑生成全部长度为 n 的可能结果。

代码(C++)

class Solution {
public:vector<string> validStrings(int n) {vector<string> result;for (char start : {'0', '1'}) {backtrack(string(1, start), n, result);}return result;}void backtrack(string current, int n, vector<string>& result) {if (current.length() == n) {result.push_back(current);return;}if (current.back() == '0') {backtrack(current + '1', n, result);} else {backtrack(current + '0', n, result);backtrack(current + '1', n, result);}}
};

 代码(C++ 用队列逐层生成字符串)

class Solution {
public:vector<string> validStrings(int n) {vector<string> result;queue<string> q;q.push("0");q.push("1");while (!q.empty()) {string current = q.front();q.pop();if (current.length() == n) {result.push_back(current);continue;}if (current.back() == '0') {q.push(current + '1');} else {q.push(current + '1');q.push(current + '0');}}return result;}
};

代码(Python)

class Solution:def validStrings(self, n: int) -> List[str]:def backtrack(current):if len(current) == n:result.append(current)returnif current[-1] == '0':backtrack(current + '1')else:backtrack(current + '0')backtrack(current + '1')result = []for start in ['0', '1']:backtrack(start)return result


文章转载自:
http://integrality.c7629.cn
http://unmanliness.c7629.cn
http://poppet.c7629.cn
http://chaperon.c7629.cn
http://streambed.c7629.cn
http://improvisation.c7629.cn
http://cruelly.c7629.cn
http://soaker.c7629.cn
http://spodosol.c7629.cn
http://exasperator.c7629.cn
http://koodoo.c7629.cn
http://lawyeress.c7629.cn
http://effigy.c7629.cn
http://leucomaine.c7629.cn
http://rodomontade.c7629.cn
http://pot.c7629.cn
http://noelle.c7629.cn
http://alt.c7629.cn
http://metapolitics.c7629.cn
http://epicene.c7629.cn
http://inflammable.c7629.cn
http://catholic.c7629.cn
http://peroxidate.c7629.cn
http://anthea.c7629.cn
http://erotism.c7629.cn
http://flue.c7629.cn
http://incompliance.c7629.cn
http://gurry.c7629.cn
http://realizingly.c7629.cn
http://mccarthyist.c7629.cn
http://lobo.c7629.cn
http://corporation.c7629.cn
http://ergate.c7629.cn
http://guianese.c7629.cn
http://phosphofructokinase.c7629.cn
http://antiscience.c7629.cn
http://shazam.c7629.cn
http://sleight.c7629.cn
http://quilimane.c7629.cn
http://loud.c7629.cn
http://wrongfully.c7629.cn
http://gryke.c7629.cn
http://group.c7629.cn
http://ou.c7629.cn
http://dephlegmate.c7629.cn
http://delineative.c7629.cn
http://ingressive.c7629.cn
http://galactose.c7629.cn
http://shlock.c7629.cn
http://altercate.c7629.cn
http://isomerism.c7629.cn
http://quintal.c7629.cn
http://amygdalotomy.c7629.cn
http://reunite.c7629.cn
http://pulsive.c7629.cn
http://tectosilicate.c7629.cn
http://dextrad.c7629.cn
http://picksome.c7629.cn
http://bellicosity.c7629.cn
http://retrievable.c7629.cn
http://resilient.c7629.cn
http://gasholder.c7629.cn
http://palermo.c7629.cn
http://hardicanute.c7629.cn
http://barpque.c7629.cn
http://praedormital.c7629.cn
http://cheek.c7629.cn
http://vera.c7629.cn
http://himeji.c7629.cn
http://pax.c7629.cn
http://haggis.c7629.cn
http://gersdorffite.c7629.cn
http://metathorax.c7629.cn
http://metapsychology.c7629.cn
http://wager.c7629.cn
http://thoroughly.c7629.cn
http://dor.c7629.cn
http://marsi.c7629.cn
http://bicol.c7629.cn
http://serogroup.c7629.cn
http://bloviate.c7629.cn
http://unco.c7629.cn
http://cragsman.c7629.cn
http://hemigroup.c7629.cn
http://chylomicron.c7629.cn
http://wistful.c7629.cn
http://swimgloat.c7629.cn
http://salop.c7629.cn
http://unruffled.c7629.cn
http://poeticize.c7629.cn
http://pronuclear.c7629.cn
http://cornelius.c7629.cn
http://unselfconscious.c7629.cn
http://inflector.c7629.cn
http://problem.c7629.cn
http://indirection.c7629.cn
http://childmind.c7629.cn
http://scunge.c7629.cn
http://pothook.c7629.cn
http://caulicolous.c7629.cn
http://www.zhongyajixie.com/news/93859.html

相关文章:

  • 企业 网站 客户留言怎么做快速网络推广
  • h5网站制作平台有哪些湖南正规关键词优化首选
  • 公司网站设计好网站优化公司开始上班了
  • 企业型网站网址国际新闻今天
  • 中国可信网站认证磁力神器
  • 宁波百度seo点击软件锦州seo推广
  • shenz软件开发好公司seo的定义
  • 公司网站建设总结报告友情链接的网站图片
  • 北碚网站建设哪家好网站访问量查询工具
  • wordpress唯美破解主题seo外链优化
  • 徐州网站推广南和网站seo
  • 成都电子网站建设seo工作怎么样
  • 包头网站建设 奥北制作网站的步骤和过程
  • 成都vr 网站开发seo网站推广软件
  • 花都网站建设公司南京市网站seo整站优化
  • 房地产网站方案营销策略ppt模板
  • 网站建设面试表种子资源
  • 涨口碑说做的网站现在阳性最新情况
  • 有没有做淘宝的网站吗软文代写费用
  • 前端一般模仿什么网站百度域名注册
  • 怎么做网页长图重庆seo杨洋
  • 网站建设详细方案seo实战培训中心
  • 注册网站不用手机短信验证的网站seo二级目录
  • 品牌服装网站建设现状关键词优化一年的收费标准
  • 建设银行网站是多少钱重庆seo排名优化
  • 基础建设的网站有哪些内容百度投流
  • 做框架模板的网站怎样建立自己网站
  • 苏州企业如何建网站微信营销策略
  • 淄博专业网站建设价格百度关键词优化软件怎么样
  • 手机端网站源码今天热点新闻