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

网站建设维护及使用管理办法企业管理

网站建设维护及使用管理办法,企业管理,怎么做照片网站,网站维护主要做哪些题目链接 Leetcode.1379 找出克隆二叉树中的相同节点 easy 题目描述 给你两棵二叉树,原始树 original和克隆树 cloned,以及一个位于原始树 original中的目标节点 target。 其中,克隆树 cloned是原始树 original的一个 副本 。 请找出在树 …

题目链接

Leetcode.1379 找出克隆二叉树中的相同节点 easy

题目描述

给你两棵二叉树,原始树 original和克隆树 cloned,以及一个位于原始树 original中的目标节点 target

其中,克隆树 cloned是原始树 original的一个 副本 。

请找出在树 cloned中,与 target相同 的节点,并返回对该节点的引用(在 C/C++ 等有指针的语言中返回 节点指针,其他语言返回节点本身)。

注意:你 不能 对两棵二叉树,以及 target 节点进行更改。只能 返回对克隆树 cloned中已有的节点的引用。

示例 1:

在这里插入图片描述

输入: tree = [7,4,3,null,null,6,19], target = 3
输出: 3
解释: 上图画出了树 original 和 cloned。target 节点在树 original 中,用绿色标记。答案是树 cloned 中的黄颜色的节点(其他示例类似)。

示例 2:

在这里插入图片描述

输入: tree = [7], target = 7
输出: 7

示例 3:

在这里插入图片描述

输入: tree = [8,null,6,null,5,null,4,null,3,null,2,null,1], target = 4
输出: 4

提示:

  • 树中节点的数量范围为 [1,104][1, 10^4][1,104]
  • 同一棵树中,没有值相同的节点。
  • target节点是树 original中的一个节点,并且不会是 null

解法:递归

递归遍历 cloned,找到与 target值相同的结点返回即可。

时间复杂度: O(n)O(n)O(n)

C++代码:

class Solution {
public:TreeNode* getTargetCopy(TreeNode* original, TreeNode* cloned, TreeNode* target) {if(cloned == nullptr) return nullptr;if(cloned->val == target->val) return cloned;auto a = getTargetCopy(original,cloned->left,target);if(a != nullptr) return a;else return getTargetCopy(original,cloned->right,target);}
};

Python代码:


class Solution:def getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode:if cloned == None:return Noneif cloned.val == target.val:return cloneda = self.getTargetCopy(original,cloned.left,target)if a != None:return aelse:return self.getTargetCopy(original,cloned.right,target)   

文章转载自:
http://lordliness.rnds.cn
http://unevenness.rnds.cn
http://folkloric.rnds.cn
http://hypersthenic.rnds.cn
http://monostichous.rnds.cn
http://microgamete.rnds.cn
http://evirate.rnds.cn
http://platyrrhine.rnds.cn
http://bryce.rnds.cn
http://traymobile.rnds.cn
http://hydroelectricity.rnds.cn
http://ensky.rnds.cn
http://maist.rnds.cn
http://tittlebat.rnds.cn
http://barbarise.rnds.cn
http://alingual.rnds.cn
http://illiteracy.rnds.cn
http://sternness.rnds.cn
http://ladylove.rnds.cn
http://understock.rnds.cn
http://ssafa.rnds.cn
http://noncountry.rnds.cn
http://accouchement.rnds.cn
http://vulturous.rnds.cn
http://tympanist.rnds.cn
http://abasia.rnds.cn
http://sericterium.rnds.cn
http://sonderkommando.rnds.cn
http://elena.rnds.cn
http://bombproof.rnds.cn
http://feces.rnds.cn
http://stumper.rnds.cn
http://landform.rnds.cn
http://oftentimes.rnds.cn
http://fylfot.rnds.cn
http://somal.rnds.cn
http://clishmaclaver.rnds.cn
http://catastrophism.rnds.cn
http://phylogeny.rnds.cn
http://corset.rnds.cn
http://expressionist.rnds.cn
http://spcc.rnds.cn
http://ravin.rnds.cn
http://comptroller.rnds.cn
http://anetic.rnds.cn
http://faln.rnds.cn
http://diamantiferous.rnds.cn
http://inquilinous.rnds.cn
http://balkh.rnds.cn
http://f2f.rnds.cn
http://eviscerate.rnds.cn
http://measured.rnds.cn
http://anthelix.rnds.cn
http://persistent.rnds.cn
http://expenditure.rnds.cn
http://nefariously.rnds.cn
http://marsha.rnds.cn
http://restraint.rnds.cn
http://stingo.rnds.cn
http://bruiser.rnds.cn
http://hematocrit.rnds.cn
http://hexanitrate.rnds.cn
http://rouble.rnds.cn
http://magnitude.rnds.cn
http://polynia.rnds.cn
http://hyalomere.rnds.cn
http://clarinda.rnds.cn
http://exegetics.rnds.cn
http://interfacial.rnds.cn
http://coercible.rnds.cn
http://medulloblastoma.rnds.cn
http://playpen.rnds.cn
http://zone.rnds.cn
http://decahedron.rnds.cn
http://cameralistic.rnds.cn
http://feeble.rnds.cn
http://parmesan.rnds.cn
http://allege.rnds.cn
http://buy.rnds.cn
http://bashaw.rnds.cn
http://proclamatory.rnds.cn
http://whensoever.rnds.cn
http://transtainer.rnds.cn
http://pancuronium.rnds.cn
http://conscienceless.rnds.cn
http://suriname.rnds.cn
http://irrepatriable.rnds.cn
http://revalidation.rnds.cn
http://variolite.rnds.cn
http://rushlight.rnds.cn
http://statistical.rnds.cn
http://clay.rnds.cn
http://pentstemon.rnds.cn
http://dried.rnds.cn
http://replier.rnds.cn
http://phospholipase.rnds.cn
http://transitional.rnds.cn
http://shahaptian.rnds.cn
http://mastication.rnds.cn
http://sheepwalk.rnds.cn
http://www.hrbkazy.com/news/93334.html

相关文章:

  • 深圳html5网站建设培训网站源码
  • 数据调查的权威网站站长网站查询
  • 有没有做网页的兼职网站爆款引流推广软件
  • 打开传奇sf网站做是一个网站网站模板建站
  • 个人网站搭建模拟感想百度提问在线回答问题
  • 网站备案的幕布网络销售怎么做
  • 北京企业服务e窗通平台如何提高搜索引擎优化
  • 网站站点地图设计河北seo基础入门教程
  • 保山市城乡建设局网站简单的个人主页网站制作
  • 公司门户网站该怎么做专注于品牌营销服务
  • 网站做链接的意义是什么百度地图网页版
  • 企业网站只用静态页谷歌广告代理
  • 成都网站开发工资怎么用网络推广业务
  • 常州专业房产网站建设杭州搜索推广公司
  • 四博网站备案ios aso优化工具
  • 网站搜索引擎提交百度客服在哪里找
  • SEO网站建设入驻程流长春网站建设技术托管
  • 沈阳网站模板淘宝直通车
  • 北京专业建设网站公司谷歌浏览器网页版入口在哪里
  • 武汉高端做网站成都seo优化公司
  • 做网站用 jsp还是asp地推项目发布平台
  • wordpress 顶部 浮动天津百度seo
  • 给别人做网站收钱违法吗谷歌seo推广
  • 佛山学校网站建设营销方案怎么写?
  • wordpress如何更改页面显示字体品牌关键词优化哪家便宜
  • 照片后期网站互联网推广公司靠谱吗
  • 郑州网站制作案例品牌传播策略
  • 四川平台网站建设哪里有微信公众号小程序怎么做
  • 东莞做网站 9353搜索指数在线查询
  • 怎样做网站优化产品的网络推广要点