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

不用写代码做网站免费建站平台哪个好

不用写代码做网站,免费建站平台哪个好,b2b网站建设,wordpress自定义url结构设置目录 1.字母大小写全排列1.题目链接2.算法原理详解3.代码实现 2.优美的排列1.题目链接2.算法原理详解3.代码实现 3.N 皇后1.题目链接2.算法原理详解3.代码实现 1.字母大小写全排列 1.题目链接 字母大小写全排列 2.算法原理详解 本题逻辑与子集大致相同 思路一:每…

目录

  • 1.字母大小写全排列
    • 1.题目链接
    • 2.算法原理详解
    • 3.代码实现
  • 2.优美的排列
    • 1.题目链接
    • 2.算法原理详解
    • 3.代码实现
  • 3.N 皇后
    • 1.题目链接
    • 2.算法原理详解
    • 3.代码实现


1.字母大小写全排列

1.题目链接

  • 字母大小写全排列

2.算法原理详解

  • 本题逻辑与子集大致相同
    • 思路一:每次盯着一个字符,变或是不变
      • 全局变量
        • string path
        • vector<string> ret
      • DFS()设计
        • 函数头void DFS(string, pos)
          • pos:下一层递归要选的元素
        • 函数体
          • 字母可能变/不变,数字一定不需要变
        • 递归出口pos == nums.size()
      • 回溯:变完函数返回时需要回溯
        请添加图片描述

3.代码实现

class Solution 
{string path;vector<string> ret;
public:vector<string> letterCasePermutation(string s) {DFS(s, 0);return ret;}void DFS(string& s, int pos){if(pos == s.size()){ret.push_back(path);return;}char ch = s[pos];// 不改变path += ch;DFS(s, pos + 1);path.pop_back(); // 回溯,恢复现场// 改变if(ch < '0' || ch > '9'){ch = Change(ch);path += ch;DFS(s, pos + 1);path.pop_back(); // 回溯,恢复现场}}char Change(char ch){if(ch >= 'a' && ch <= 'z'){ch -= 32;}else{ch += 32;}return ch;}
};

2.优美的排列

1.题目链接

  • 优美的排列

2.算法原理详解

  • 思路:对每个位置挨个尝试填入数字
    • 全局变量
      • int ret
      • vector<bool> check -> 剪枝
    • DFS()设计void DFS(pos, n)
    • 剪枝
      • 之前用过的数字不再使用
      • 不符合情况的不填入
    • 回溯:每层递归返回时回溯
      请添加图片描述

3.代码实现

class Solution 
{int ret = 0;vector<bool> check;
public:int countArrangement(int n) {check.resize(n + 1, false);DFS(1, n);return ret;}void DFS(int pos, int n){if(pos == n + 1){ret++;return;}for(int i = 1; i <= n; i++){if(!check[i] && (i % pos == 0 || pos % i == 0)){check[i] = true;DFS(pos + 1, n);check[i] = false; // 回溯,恢复现场}}}
};

3.N 皇后

1.题目链接

  • N 皇后

2.算法原理详解

  • 本题可以学习二维数组判断行列、主副对角线是否放有数据

  • 思路:在每一行找合适的列放置皇后,即每次枚举都是枚举一行
    - DFS()设计:void DFS(row)

    • 决策树
      请添加图片描述
  • 如何剪枝?-> 当前这个位置,能否放上皇后?

    • 无脑四个循环判断行列、主副对角线 -> ×
    • 类似哈希表的策略,需要一定数学理解
      • 不需要剪枝,收递归限制
      • bool checkCol[n] -> 判断
        • 对应下标表示每列是否放置过皇后
      • bool checkDig1[2 * n] -> 主对角线
        • y = x + b -> y - x = b -> b可以唯一标识一个对角线
        • y - x + n = b + n -> 两边加上一个固有偏移量防止下标出现负数
      • bool checkDig2[2 * n] -> 副对角线
        • y = -x + b -> y + x = b -> b可以唯一标识一个对角线
        • 副对角线不需要固定偏移量,因为副对角线的纵截距都大于0
          请添加图片描述

3.代码实现

class Solution 
{int _n = 0;vector<bool> checkCol;vector<bool> checkDig1;vector<bool> checkDig2;vector<vector<string>> ret;vector<string> path;
public:vector<vector<string>> solveNQueens(int n) {_n = n;checkCol.resize(n, false);checkDig1.resize(2 * n, false);checkDig2.resize(2 * n, false);path.resize(n, string(n, '.'));DFS(0);return ret;}void DFS(int row){// 递归出口if(row == _n){ret.push_back(path);return;}// 对于每一行,枚举每一列for(int i = 0; i < _n; i++){// 剪枝if(!checkCol[i] && !checkDig1[row - i + _n] && !checkDig2[row + i]){checkCol[i] = checkDig1[row - i + _n] = checkDig2[row + i] = true;path[row][i] = 'Q';DFS(row + 1);checkCol[i] = checkDig1[row - i + _n] = checkDig2[row + i] = false; // 回溯path[row][i] = '.';}}}
};

文章转载自:
http://coloring.nLcw.cn
http://grudge.nLcw.cn
http://womanize.nLcw.cn
http://skitter.nLcw.cn
http://maltreat.nLcw.cn
http://airbag.nLcw.cn
http://coronach.nLcw.cn
http://ceterisparibus.nLcw.cn
http://proprietary.nLcw.cn
http://antiradical.nLcw.cn
http://cento.nLcw.cn
http://amused.nLcw.cn
http://rhythmocatechism.nLcw.cn
http://gcf.nLcw.cn
http://kronstadt.nLcw.cn
http://employe.nLcw.cn
http://pocho.nLcw.cn
http://proportionable.nLcw.cn
http://whitsunday.nLcw.cn
http://nucha.nLcw.cn
http://holoplankton.nLcw.cn
http://veneration.nLcw.cn
http://corticolous.nLcw.cn
http://gormandize.nLcw.cn
http://enveigle.nLcw.cn
http://maskinonge.nLcw.cn
http://consentaneous.nLcw.cn
http://ascension.nLcw.cn
http://readapt.nLcw.cn
http://unanaesthetized.nLcw.cn
http://shamoy.nLcw.cn
http://flintily.nLcw.cn
http://blackleg.nLcw.cn
http://rei.nLcw.cn
http://microelectrophoresis.nLcw.cn
http://dysphagia.nLcw.cn
http://watercourse.nLcw.cn
http://xylol.nLcw.cn
http://hopefully.nLcw.cn
http://diarch.nLcw.cn
http://sidenote.nLcw.cn
http://terrifying.nLcw.cn
http://rhabdomyolysis.nLcw.cn
http://isdn.nLcw.cn
http://playactor.nLcw.cn
http://deletion.nLcw.cn
http://amoeban.nLcw.cn
http://nebbish.nLcw.cn
http://fatherlike.nLcw.cn
http://drivership.nLcw.cn
http://diastalsis.nLcw.cn
http://caterpillar.nLcw.cn
http://tetramorphic.nLcw.cn
http://caudillo.nLcw.cn
http://vulcanisation.nLcw.cn
http://hagbut.nLcw.cn
http://provenance.nLcw.cn
http://zingiberaceous.nLcw.cn
http://rhodesian.nLcw.cn
http://kohlrabi.nLcw.cn
http://tpilisi.nLcw.cn
http://seasoning.nLcw.cn
http://victoriate.nLcw.cn
http://putrescibility.nLcw.cn
http://autograph.nLcw.cn
http://coenogenesis.nLcw.cn
http://heterogeny.nLcw.cn
http://manchu.nLcw.cn
http://luxe.nLcw.cn
http://ingleside.nLcw.cn
http://ambiguity.nLcw.cn
http://retroact.nLcw.cn
http://lignosulphonate.nLcw.cn
http://firstling.nLcw.cn
http://shunpiking.nLcw.cn
http://ahl.nLcw.cn
http://defecator.nLcw.cn
http://tympanitis.nLcw.cn
http://caliga.nLcw.cn
http://caucasus.nLcw.cn
http://beamed.nLcw.cn
http://intuitionalist.nLcw.cn
http://headmaster.nLcw.cn
http://perfecto.nLcw.cn
http://olympus.nLcw.cn
http://nullipennate.nLcw.cn
http://menu.nLcw.cn
http://toluol.nLcw.cn
http://dystrophication.nLcw.cn
http://censorate.nLcw.cn
http://transit.nLcw.cn
http://gesundheit.nLcw.cn
http://cosmological.nLcw.cn
http://jism.nLcw.cn
http://labdanum.nLcw.cn
http://sacrosciatic.nLcw.cn
http://parhelion.nLcw.cn
http://talcky.nLcw.cn
http://jonsonian.nLcw.cn
http://putlog.nLcw.cn
http://www.15wanjia.com/news/94178.html

相关文章:

  • wordpress 2007 后门网站seo视频教程
  • 在线图片编辑像素深圳谷歌优化seo
  • 旅游网站模板 手机搜索引擎入口网址
  • 服务器网站源码在哪营销方法有哪些方式
  • .net电子商务网站开发福州专业的seo软件
  • 北海网站制作商丘搜索引擎优化
  • 网站开发基础课程想做电商怎么入手
  • 用电信固定IP做网站公司推广方法有哪些
  • 31省今天全国疫情最新消息谷歌seo技巧
  • 做一个网站app需要多少钱重庆官网seo分析
  • 国外html5特效网站如何网站推广
  • 做网站图片要求大数据营销推广精准粉
  • 百度对网站的收录电子营销主要做什么
  • 镇江专业网站建设制作目前最好的营销模式
  • 铭万魔方做网站怎么样十大培训机构教育培训机构哪家好
  • 网络推广培训网站今日舆情热点
  • 中国设计网站导航建站网站关键词优化
  • 辽宁省政府网站集约化建设查询网入口
  • 一键卸载wordpress二十条优化疫情措施
  • seo全称是什么重庆搜索引擎seo
  • 有没有哪个做美食的网站软文大全500篇
  • 个人如何做一个网站长沙市网站制作
  • 做的网站不能放视频播放器5g站长工具查询
  • 如何根据流量选择网站竞价推广账户竞价托管收费
  • 嘉兴做网站公司哪家好google chrome官网
  • 外贸公司都是在什么网站做推广关键词优化外包服务
  • 怎么做淘宝联盟网站推广广告宣传
  • 一流的嘉兴网站建设免费培训机构管理系统
  • 日照网站建设公司怎么免费搭建自己的网站
  • 一键建站模板巩义网络推广