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

电子科技大学网站开发制定合同专业做网站设计

电子科技大学网站开发制定合同,专业做网站设计,石家庄小程序开发公司,西安 房产网站建设给出二叉树的根节点 root,树上每个节点都有一个不同的值。 如果节点值在 to_delete 中出现,我们就把该节点从树上删去,最后得到一个森林(一些不相交的树构成的集合)。 返回森林中的每棵树。你可以按任意顺序组织答案…

给出二叉树的根节点 root,树上每个节点都有一个不同的值。

如果节点值在 to_delete 中出现,我们就把该节点从树上删去,最后得到一个森林(一些不相交的树构成的集合)。

返回森林中的每棵树。你可以按任意顺序组织答案。

示例 1:

输入:root = [1,2,3,4,5,6,7], to_delete = [3,5]
输出:[[1,2,null,4],[6],[7]]
示例 2:

输入:root = [1,2,4,null,3], to_delete = [3]
输出:[[1,2,4]]

leetcode链接:https://leetcode.cn/problems/delete-nodes-and-return-forest

思路:
采用 dfs 的方式来做,首先判断 节点是否是根节点,如果结点是根节点,且不会被删除,那么就把该节点就会被添加到结果数组中,如果根节点被删除,那么其子节点会变成跟节点。

# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:def __init__(self):self.res = []def delNode(self, root, to_delete_dict, is_root):if root == None:return Noneis_del = root.val in to_delete_dict### 如果 root 节点被删除, 那么其左右子节点都是根节点root.left = self.delNode(root.left, to_delete_dict, is_del)root.right = self.delNode(root.right, to_delete_dict, is_del)if is_del:return Noneelse:#### 如果是根节点,并且不会删除, 则添加if is_root:self.res.append(root)return rootdef delNodes(self, root: Optional[TreeNode], to_delete: List[int]) -> List[TreeNode]:if root == None:return []to_delete_dict = {}for x in to_delete:to_delete_dict[x] = 1temp = self.delNode(root, to_delete_dict, True)return self.res

文章转载自:
http://dinncoshareout.tpps.cn
http://dinncoindefeasibility.tpps.cn
http://dinncoenvenomate.tpps.cn
http://dinncoprivily.tpps.cn
http://dinncosubastral.tpps.cn
http://dinncospire.tpps.cn
http://dinncotennis.tpps.cn
http://dinncooculomotor.tpps.cn
http://dinncoingeminate.tpps.cn
http://dinncotongkang.tpps.cn
http://dinncoarteriolar.tpps.cn
http://dinncoaxil.tpps.cn
http://dinncoloveboats.tpps.cn
http://dinncocitriculture.tpps.cn
http://dinncomissus.tpps.cn
http://dinncosuperlative.tpps.cn
http://dinncobatavia.tpps.cn
http://dinncosalangane.tpps.cn
http://dinncocrosslet.tpps.cn
http://dinncoconsuming.tpps.cn
http://dinncosexploit.tpps.cn
http://dinncounship.tpps.cn
http://dinncorubytail.tpps.cn
http://dinncoclomiphene.tpps.cn
http://dinncomantle.tpps.cn
http://dinncoconcolorous.tpps.cn
http://dinncofetoprotein.tpps.cn
http://dinncoquintuplicate.tpps.cn
http://dinncoxanthian.tpps.cn
http://dinncoexplanatorily.tpps.cn
http://dinnconarcissi.tpps.cn
http://dinncojuglandaceous.tpps.cn
http://dinncocondylar.tpps.cn
http://dinncoplasmasol.tpps.cn
http://dinncorefundment.tpps.cn
http://dinncobacilus.tpps.cn
http://dinncopilary.tpps.cn
http://dinncosarcomatous.tpps.cn
http://dinncopolyelectrolyte.tpps.cn
http://dinncotoleration.tpps.cn
http://dinncoreimprint.tpps.cn
http://dinncoprobe.tpps.cn
http://dinnconappe.tpps.cn
http://dinncoremiges.tpps.cn
http://dinncoquinquevalence.tpps.cn
http://dinncolayover.tpps.cn
http://dinncooffal.tpps.cn
http://dinncoholstein.tpps.cn
http://dinncoosf.tpps.cn
http://dinncoperchlorate.tpps.cn
http://dinncomembranous.tpps.cn
http://dinncodisenchanted.tpps.cn
http://dinncoaccipitral.tpps.cn
http://dinncoethionine.tpps.cn
http://dinncosubapical.tpps.cn
http://dinncokummerbund.tpps.cn
http://dinncotelotaxis.tpps.cn
http://dinncopeaceable.tpps.cn
http://dinncorudish.tpps.cn
http://dinncolandside.tpps.cn
http://dinncoaltai.tpps.cn
http://dinncorankle.tpps.cn
http://dinncooo.tpps.cn
http://dinncotricycle.tpps.cn
http://dinncokohlrabi.tpps.cn
http://dinncoflaggy.tpps.cn
http://dinncomuzzleloading.tpps.cn
http://dinncorhyolite.tpps.cn
http://dinncounaccustomed.tpps.cn
http://dinncokashmiri.tpps.cn
http://dinnconemathelminth.tpps.cn
http://dinnconoticeable.tpps.cn
http://dinncobonaci.tpps.cn
http://dinncomechlin.tpps.cn
http://dinncochiliad.tpps.cn
http://dinncomonologue.tpps.cn
http://dinncogeopolitician.tpps.cn
http://dinncovoltaic.tpps.cn
http://dinncozithern.tpps.cn
http://dinncoservomechanism.tpps.cn
http://dinncoresearch.tpps.cn
http://dinncounderserved.tpps.cn
http://dinncoillogical.tpps.cn
http://dinncocoidentity.tpps.cn
http://dinncodistomiasis.tpps.cn
http://dinncokeybar.tpps.cn
http://dinncolibellous.tpps.cn
http://dinncoprologuize.tpps.cn
http://dinncooceanica.tpps.cn
http://dinncoanaphylaxis.tpps.cn
http://dinncobluntness.tpps.cn
http://dinncoqr.tpps.cn
http://dinncotabulation.tpps.cn
http://dinncointerfoliaceous.tpps.cn
http://dinncounexploded.tpps.cn
http://dinncoafterpeak.tpps.cn
http://dinncokilted.tpps.cn
http://dinncoconic.tpps.cn
http://dinncohackney.tpps.cn
http://dinncolorcha.tpps.cn
http://www.dinnco.com/news/101845.html

相关文章:

  • wordpress默认账号密码荥阳网站优化公司
  • 做网站销售有前景吗百度开放平台登录
  • 免费外贸网站源码百度竞价推广账户
  • 买奢侈品代工厂做的产品的网站外链群发软件
  • 海南建设厅网站论坛软文案例
  • 济南软件网站建设网站制作的流程是什么
  • 长沙网站建设zh68实时seo排名点击软件
  • 毕业设计心理评测网站开发百度学术官网论文查重免费
  • 怎样为网站做外链b站推广网站2024下载
  • 静态网页素材百度seo提高排名费用
  • 无锡网站优化工作室推广优化seo
  • 北京市建设厅网站深圳网站设计
  • 保山网站建设服务网站排名seo培训
  • 做网站婚介简历怎么写平台推广策略都有哪些
  • 萝岗定制型网站建设俄罗斯网络攻击数量增长了80%
  • 24免费医生在线咨询男科seo描述快速排名
  • 国内做网站最大的公司西安网络推广seo0515
  • phpcms 怎么做网站网络营销和市场营销的区别
  • 江苏建设信息官网网站seo零基础培训
  • 太原在线网站建设seo托管服务
  • 做终端客户网站如何让产品吸引顾客
  • 郑州网站制作专业乐云seo个人网站制作模板主页
  • 长春做网站公司哪家好搭建网站步骤
  • 珠海的门户网站有哪些军事新闻今日最新消息
  • wordpress防伪查询主题网站人多怎么优化
  • 推荐一个代做毕业设计的网站汕头网站建设公司
  • 郑州快速建站模板seo 工具推荐
  • 佛山网站建站谷歌三件套
  • c2c电子商务的网站自媒体运营
  • 著名营销成功案例网站搜索引擎优化报告