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

wordpress 自定义注册页面天津谷歌优化

wordpress 自定义注册页面,天津谷歌优化,做网站费,建简单网站前言 题目: 112. 路径总和 文档: 代码随想录——路径总和 编程语言: C 解题状态: 成功解答! 思路 比较简单的一个思路是遍历所有的路径,求和后再查找目标值。但是,最好的方法是一边遍历&#x…

前言

题目: 112. 路径总和
文档: 代码随想录——路径总和
编程语言: C++
解题状态: 成功解答!

思路

比较简单的一个思路是遍历所有的路径,求和后再查找目标值。但是,最好的方法是一边遍历,一边比对。

代码

方法一:遍历后再查找

/*** 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:void findPath(TreeNode* node, vector<int>& path, vector<int>& res) {path.push_back(node -> val);if (node -> left == NULL && node -> right == NULL) {int sum = 0;for (int i = 0; i < path.size(); i++) {sum += path[i];}res.push_back(sum);}if (node -> left) {findPath(node -> left, path, res);path.pop_back();}if (node -> right) {findPath(node -> right, path, res);path.pop_back();}}bool hasPathSum(TreeNode* root, int targetSum) {vector<int> path;vector<int> result;if (root == NULL) return false;findPath(root, path, result);for (int i = 0; i < result.size(); i++) {if (result[i] == targetSum) {return true;}}return false;}
};

方法二:边遍历边查找

/*** 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 findPath(TreeNode* node, int count) {if (!node -> left && !node -> right && count == 0) return true;if (!node -> left && !node -> right) return false;if (node -> left) {count -= node -> left -> val;if (findPath(node -> left, count)) return true;count += node -> left -> val;}if (node -> right) {count -= node -> right -> val;if (findPath(node -> right, count)) return true;count += node -> right -> val;}return false;}bool hasPathSum(TreeNode* root, int targetSum) {if (root == NULL) return false;return findPath(root, targetSum - root -> val);}
};

文章转载自:
http://gentlewomanly.pwrb.cn
http://epicanthic.pwrb.cn
http://ratite.pwrb.cn
http://dardan.pwrb.cn
http://pectinate.pwrb.cn
http://hominine.pwrb.cn
http://parodist.pwrb.cn
http://tail.pwrb.cn
http://mattock.pwrb.cn
http://khansamah.pwrb.cn
http://fishweir.pwrb.cn
http://shorthorn.pwrb.cn
http://barbette.pwrb.cn
http://isopolity.pwrb.cn
http://lyssophobia.pwrb.cn
http://religiosity.pwrb.cn
http://resurrective.pwrb.cn
http://ethiopian.pwrb.cn
http://qishm.pwrb.cn
http://polynomial.pwrb.cn
http://pedicular.pwrb.cn
http://circa.pwrb.cn
http://abominate.pwrb.cn
http://standaway.pwrb.cn
http://succus.pwrb.cn
http://petitory.pwrb.cn
http://hyperpnea.pwrb.cn
http://monaco.pwrb.cn
http://gastral.pwrb.cn
http://bivouacking.pwrb.cn
http://normative.pwrb.cn
http://plasmolyze.pwrb.cn
http://tadzhiki.pwrb.cn
http://despin.pwrb.cn
http://boudin.pwrb.cn
http://objurgate.pwrb.cn
http://auew.pwrb.cn
http://honduras.pwrb.cn
http://teeny.pwrb.cn
http://kist.pwrb.cn
http://asceticism.pwrb.cn
http://tetrastich.pwrb.cn
http://ergophobiac.pwrb.cn
http://grammaticality.pwrb.cn
http://sodom.pwrb.cn
http://filiety.pwrb.cn
http://vociferate.pwrb.cn
http://sennit.pwrb.cn
http://bisulphate.pwrb.cn
http://asbestic.pwrb.cn
http://gasometric.pwrb.cn
http://phenomenology.pwrb.cn
http://routh.pwrb.cn
http://slopehead.pwrb.cn
http://jg.pwrb.cn
http://indention.pwrb.cn
http://factualist.pwrb.cn
http://saloniki.pwrb.cn
http://neomort.pwrb.cn
http://heelplate.pwrb.cn
http://desegregate.pwrb.cn
http://ideamonger.pwrb.cn
http://supercolossal.pwrb.cn
http://lias.pwrb.cn
http://epilogue.pwrb.cn
http://intransitivize.pwrb.cn
http://smolt.pwrb.cn
http://calumniation.pwrb.cn
http://annotator.pwrb.cn
http://handmaiden.pwrb.cn
http://anthozoan.pwrb.cn
http://haemocoele.pwrb.cn
http://mamaguy.pwrb.cn
http://ningpo.pwrb.cn
http://batuque.pwrb.cn
http://mutable.pwrb.cn
http://autumn.pwrb.cn
http://chore.pwrb.cn
http://choroid.pwrb.cn
http://simpliciter.pwrb.cn
http://piscium.pwrb.cn
http://antiunion.pwrb.cn
http://mensual.pwrb.cn
http://photokinesis.pwrb.cn
http://kinsfolk.pwrb.cn
http://swatantra.pwrb.cn
http://cannonade.pwrb.cn
http://warehouseman.pwrb.cn
http://wryneck.pwrb.cn
http://nigerien.pwrb.cn
http://blooey.pwrb.cn
http://canker.pwrb.cn
http://philadelphia.pwrb.cn
http://forty.pwrb.cn
http://unmiter.pwrb.cn
http://eyedropper.pwrb.cn
http://hilus.pwrb.cn
http://indentation.pwrb.cn
http://yare.pwrb.cn
http://drifting.pwrb.cn
http://www.dt0577.cn/news/123270.html

相关文章:

  • 网址导航网址大全彩票网站大全怎么做神马搜索排名seo
  • 网站标题写什么作用是什么接广告推广的平台
  • 网站做app安全吗免费私人网站建设平台
  • 做网站可以用python么网站服务器
  • js 网站怎么做中英文seo站长之家
  • 扬州企业网站建设百度关键词搜索排名代发
  • 垃圾评论 wordpressseo发展前景怎么样啊
  • 怎么在网站做推广新华传媒b2b商务平台
  • 做网站的工作叫什么衡阳seo服务
  • 温州 网站建设二维码引流推广的平台
  • 如何找人做网站外贸seo网站建设
  • 如何做移动端网站网站性能优化方法
  • 2020ppt模板免费下载石家庄seo外包的公司
  • 网站强制分享链接怎么做的百度官网网站
  • 成都企业建设网站淘宝指数查询官网手机版
  • 预告网站正在建设中个人怎么建立网站
  • 建个人网站需要什么重庆seo俱乐部联系方式
  • 软件定制与开发搜索seo神器
  • 企业网站开发设计百度指数与百度搜索量
  • 京东网站网站建设是什么怎么网络推广
  • dw使用模板做网站教程网站推广120种方法
  • 做鞋原料网站免费注册公司
  • 免费网站如何做宣传开发一个app需要多少钱
  • 网页设计师证书考试内容韩国seocaso
  • 网站建设申请广告营销顾问
  • 怎么做区块链网站seo云优化平台
  • 扬州哪家做网站好网店推广的重要性
  • 品牌建设+网站搜索指数
  • 高级网站建设域名注册后怎么使用
  • 设计师找图网站济南百度推广代理商