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

单页网站内链接哪里有网页设计

单页网站内链接,哪里有网页设计,有几个网站打不开,龙海市城乡建设局网站226.翻转二叉树 题目链接#xff1a;226.翻转二叉树思路#xff1a;遍历二叉树#xff0c;遍历的时候交换左右节点即可代码#xff1a; TreeNode* invertTree(TreeNode* root) {reverse(root);return root;}// 迭代法#xff0c;层序遍历void f2(TreeNode* root) {queue…226.翻转二叉树 题目链接226.翻转二叉树思路遍历二叉树遍历的时候交换左右节点即可代码 TreeNode* invertTree(TreeNode* root) {reverse(root);return root;}// 迭代法层序遍历void f2(TreeNode* root) {queueTreeNode* que;if (root ! NULL) que.push(root);while (!que.empty()) {int size que.size();for (int i 0; i size; i) {TreeNode* node que.front();que.pop();swap(node-left, node-right); // 节点处理if (node-left) que.push(node-left);if (node-right) que.push(node-right);}}return root;}// 递归法void reverse(TreeNode* root) {if(!root)return;TreeNode* l root-left;TreeNode* r root-right;reverse(l);reverse(r);root-left r;root-right l;} 101. 对称二叉树 题目链接101. 对称二叉树思路遍历的时候分别遍历比较左子树的右子树和右子树的做子树左子树的左子树和右子树的右子树对应即可代码 /*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode() : val(0), left(nullptr), right(nullptr) {}* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}* };*/ class Solution { public:// 递归法bool isEqual(TreeNode* right, TreeNode* left) {if(!right || !left)return right left;return right-val left-val isEqual(right-left, left-right) isEqual(right-right, left-left);}// 迭代法bool isEqualIter(TreeNode* u, TreeNode* v) {queue TreeNode* q;q.push(u); q.push(v);while (!q.empty()) {u q.front(); q.pop();v q.front(); q.pop();if (!u !v) continue;if ((!u || !v) || (u-val ! v-val)) return false;q.push(u-left); q.push(v-right);q.push(u-right); q.push(v-left);}return true;}bool isSymmetric(TreeNode* root) {if(!root)return true;return isEqualIter(root-left, root-right);} }; 104.二叉树的最大深度 题目链接104.二叉树的最大深度思路遍历二叉树记录最大深度即可代码 class Solution { public:// 递归法int maxRecur(TreeNode* root) {if (root nullptr) {return 0;}int l_depth maxDepth(root-left);int r_depth maxDepth(root-right);return max(l_depth, r_depth) 1;}// 迭代法层序遍历int maxIter(TreeNode* root) {if (root nullptr) return 0;queueTreeNode* Q;Q.push(root);int ans 0;while (!Q.empty()) {int sz Q.size();while (sz 0) {TreeNode* node Q.front();Q.pop();if (node-left) Q.push(node-left);if (node-right) Q.push(node-right);sz - 1;}ans 1;} return ans;}int maxDepth(TreeNode* root) {return maxRecur(root);} }; 111.二叉树的最小深度 题目链接111.二叉树的最小深度思路遍历二叉树记录最小深度相比最大深度这里记录最小深度时需要记录的是到叶子节点的最小深度需要比最大深度多两个判断代码 class Solution { public:// 递归法int minDepthRecur(TreeNode *root) {if (root nullptr) {return 0;}if (root-right nullptr) {return minDepthRecur(root-left) 1; // 左子树的最小高度}if (root-left nullptr) {return minDepthRecur(root-right) 1; // 右子树的最小高度}return min(minDepthRecur(root-left), minDepthRecur(root-right)) 1;}// 迭代法层序遍历int minDepthIter(TreeNode *root) {if (root nullptr) return 0;queuepairTreeNode *, int que; // 记录节点和深度que.emplace(root, 1);while (!que.empty()) {TreeNode *node que.front().first;int depth que.front().second;que.pop();if (node-left nullptr node-right nullptr) {return depth; // 没有子树叶子节点最先到达的叶子节点的高度为最小深度}if (node-left ! nullptr) {que.emplace(node-left, depth 1); // 左子树的深度}if (node-right ! nullptr) { // 右子树的深度que.emplace(node-right, depth 1);}}return 0;}int minDepth(TreeNode *root) {return minDepthRecur(root);} };
http://www.hkea.cn/news/14431907/

相关文章:

  • 做网站就业要会什么手机商城建站系统网站建设
  • 网站建设方案 前台 后台WordPress引用阿里云矢量图
  • 无锡建设局评职称网站单位的网站的建设
  • 上海php做网站津南房地产网站建设
  • 昌平知名的网站制作建设报价手机写代码的软件
  • 网站重新备案怎么做网站策划案模板
  • 网站建设费挂什么科目wordpress建站双语
  • 做网站生意影响网站收录的因素
  • 网站开发强制开启浏览器极速模式网站建设公司 关于我们
  • 上海企业网站的建设网站建设课结课感受
  • 有哪些企业会找人做网站建设网站 怎么备案
  • 网站 linux 服务器涨粉丝1元1000个
  • 自己做网站想更换网址怎么增加网站权重
  • 深圳罗湖网站建设赣州专业做网站
  • 公司网站怎么免费建博客网站开发技术
  • 如何网站全部结构建站之星模板下载网站
  • 用服务器ip怎么做网站工程交易网
  • 做网站用的国外节点服务器深圳高端品牌网站建设
  • 三明市住房与建设局网站wordpress 上传图片插件
  • 做预售的网站dede网站开发步骤
  • 一个完整的个人网站企业微信官方网站
  • 网站开发美工的任务网站系统是一个典型的
  • 手机模板网站模板官方网站welcome怎么注册
  • 青岛专业网站设计的公司潍坊百度快速排名优化
  • 锦州滨海新区城市建设规划网站怎么优化自己网站
  • 济南商城网站建设wordpress会员推广插件
  • 宁波网站关键词推广wordpress安全检测工具
  • 网页设计与网站建设试卷网络规划与设计参考文献
  • 网页设计个人网站网站建设吉金手指排名12
  • 营销型企业网站建设体会wordpress可以建站吗