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

北京网站建设方案系统百度投诉中心24人工

北京网站建设方案系统,百度投诉中心24人工,怎样做安居客网站,不要网站域名DFS 递归: 1.判断是否失败终止 2.判断是否成功终止,如果成功的,记录一个成果 3.遍历各种选择,在这部分可以进行剪枝 4.在每种情况下进行DFS,并进行回退。 199. 二叉树的右视图 给定一个二叉树的 根节点 root&#x…

DFS

递归:
1.判断是否失败终止
2.判断是否成功终止,如果成功的,记录一个成果
3.遍历各种选择,在这部分可以进行剪枝
4.在每种情况下进行DFS,并进行回退。

199. 二叉树的右视图

给定一个二叉树的 根节点 root,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。
示例 1:
在这里插入图片描述
输入: [1,2,3,null,5,null,4]
输出: [1,3,4]
示例 2:
输入: [1,null,3]
输出: [1,3]
示例 3:
输入: []
输出: []

class Solution {
public:vector<int> rightSideView(TreeNode* root) {unordered_map<int, int> rightmostValueAtDepth;int max_depth = -1;stack<TreeNode*> nodeStack;stack<int> depthStack;nodeStack.push(root);depthStack.push(0);while (!nodeStack.empty()) {TreeNode* node = nodeStack.top();nodeStack.pop();int depth = depthStack.top();depthStack.pop();if (node != NULL) {// 维护二叉树的最大深度max_depth = max(max_depth, depth);// 如果不存在对应深度的节点我们才插入if (rightmostValueAtDepth.find(depth) == rightmostValueAtDepth.end()) {rightmostValueAtDepth[depth] =  node -> val;}nodeStack.push(node -> left);nodeStack.push(node -> right);depthStack.push(depth + 1);depthStack.push(depth + 1);}}vector<int> rightView;for (int depth = 0; depth <= max_depth; ++depth) {rightView.push_back(rightmostValueAtDepth[depth]);}return rightView;}
};

39. 组合总和

给你一个 无重复元素 的整数数组 candidates 和一个目标整数 target ,找出 candidates 中可以使数字和为目标数 target 的 所有 不同组合 ,并以列表形式返回。你可以按 任意顺序 返回这些组合。
candidates 中的 同一个 数字可以 无限制重复被选取 。如果至少一个数字的被选数量不同,则两种组合是不同的。
对于给定的输入,保证和为 target 的不同组合数少于 150 个。
示例 1:
输入:candidates = [2,3,6,7], target = 7
输出:[[2,2,3],[7]]
解释:
2 和 3 可以形成一组候选,2 + 2 + 3 = 7 。注意 2 可以使用多次。
7 也是一个候选, 7 = 7 。
仅有这两种组合。
示例 2:
输入: candidates = [2,3,5], target = 8
输出: [[2,2,2,2],[2,3,3],[3,5]]
示例 3:
输入: candidates = [2], target = 1
输出: []

class Solution {
public:void dfs(vector<int>& candidates, int target, vector<vector<int>>& ans, vector<int>& combine, int index) {if (index >= candidates.size()) return;if (target==0) {ans.emplace_back(combine);return;}dfs(candidates, target, ans, combine, index+1);if (candidates[index]<=target){combine.push_back(candidates[index]);dfs(candidates, target-candidates[index], ans, combine, index);combine.pop_back();}}vector<vector<int>> combinationSum(vector<int>& candidates, int target) {vector<vector<int>> ans;vector<int> combine;dfs(candidates, target, ans, combine, 0);return ans;}
};
http://www.tj-hxxt.cn/news/115621.html

相关文章:

  • 网站建设要做哪些潍坊网站建设优化
  • 10m光纤做网站营销网站建设培训学校
  • wordpress黑糖主题企业seo网站营销推广
  • 昆山 网站运营seo网站排名优化公司哪家好
  • 网站个人备案类型排名
  • 公司如何申请一个网站软文推广方案
  • 扬州网站建设哪个好薇国内推广平台有哪些
  • 丹东做网站公司seo关键词快速排名
  • 咨询网站 获取排名百度推广账户登录
  • 现在什么网站比较火做推广google网址直接打开
  • 男女做爰真人视频免费网站抖音推广
  • 做网站得花多少钱找客户资源的网站
  • 东丽区网站建设公司郑州seo技术服务顾问
  • 网站一般怎么推广网站seo关键词排名优化
  • apache新建网站考证培训机构
  • app企业网站模板免费下载seo优化方法有哪些
  • 下载软件网站广州网站推广运营
  • 深圳 网站建设 销售免费广告
  • 网站前端模板下载宁波seo链接优化
  • 在线做简单的网站seo免费自学的网站
  • 潍坊网站建设8年百度首页推荐关不掉吗
  • 自助做网站哪家好网站推广优化技巧
  • 网站开发框架是什么如何优化推广网站
  • 南县做网站推荐竞价托管推广代运营
  • 如果做好招聘网站建设seo入口
  • 企拓客app骗局抖音seo点击软件排名
  • 北京网站制作案例站长素材网
  • win7系统做asp网站微信广告推广平台
  • 武汉网站开发公司哪家好网络优化的流程
  • php免费源码网站互联网推广渠道