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

react怎么做pc网站微营销推广软件

react怎么做pc网站,微营销推广软件,做细胞激活的母液网站,深圳设计公司推荐记录了初步解题思路 以及本地实现代码;并不一定为最优 也希望大家能一起探讨 一起进步 目录 2/19 590. N 叉树的后序遍历2/20 105. 从前序与中序遍历序列构造二叉树2/21 106. 从中序与后序遍历序列构造二叉树2/22 889. 根据前序和后序遍历构造二叉树2/23 2583. 二叉…

记录了初步解题思路 以及本地实现代码;并不一定为最优 也希望大家能一起探讨 一起进步


目录

      • 2/19 590. N 叉树的后序遍历
      • 2/20 105. 从前序与中序遍历序列构造二叉树
      • 2/21 106. 从中序与后序遍历序列构造二叉树
      • 2/22 889. 根据前序和后序遍历构造二叉树
      • 2/23 2583. 二叉树中的第 K 大层和
      • 2/24 2476. 二叉搜索树最近节点查询
      • 2/25 235. 二叉搜索树的最近公共祖先


2/19 590. N 叉树的后序遍历

左右根 栈实现
mem记录节点是否已被处理

class Node(object):def __init__(self, val=None, children=None):self.val = valself.children = childrendef postorder(root):""":type root: Node:rtype: List[int]"""st = [root]if not root:return []ans = []mem=set()while st:node = st[-1]if len(node.children)==0 or node in mem:ans.append(node.val)st.pop()continuest.extend(reversed(node.children))mem.add(node)return ans

2/20 105. 从前序与中序遍历序列构造二叉树

根据先序遍历 根左右 确定根节点
再根据中序遍历中根节点位置 将左右子树分开

class TreeNode(object):def __init__(self, x):self.val = xself.left = Noneself.right = Nonedef buildTree(preorder, inorder):""":type preorder: List[int]:type inorder: List[int]:rtype: TreeNode"""n = len(inorder)indic = dict(zip(inorder,range(n)))def create(i, j):if i > j: return Noneroot = TreeNode(preorder.pop(0))iroot = indic[root.val]root.left = create(i,iroot-1)root.right = create(iroot+1, j)return rootreturn create(0, n - 1)

2/21 106. 从中序与后序遍历序列构造二叉树

根据后序遍历 中序遍历 生成树
从后续遍历最后确定根节点
在中序遍历中 将根节点左右子树分开

class TreeNode(object):def __init__(self, x):self.val = xself.left = Noneself.right = Nonedef buildTree(inorder,postorder):""":type preorder: List[int]:type inorder: List[int]:rtype: TreeNode"""if len(postorder)==0 or len(inorder)==0:return Nonen = len(inorder)indic = dict(zip(inorder,range(n)))def create(i, j):if i > j: return Noneroot = TreeNode(postorder.pop())iroot = indic[root.val]root.right = create(iroot+1, j)root.left = create(i, iroot-1)return rootreturn create(0, n - 1)

2/22 889. 根据前序和后序遍历构造二叉树

前序 根左右
后续 左右根
前序根后一个为左子树的根 在后续中找到这个根可以划分左右子树

class TreeNode(object):def __init__(self, x):self.val = xself.left = Noneself.right = Nonedef constructFromPrePost(preorder, postorder):""":type preorder: List[int]:type inorder: List[int]:rtype: TreeNode"""def create(pre, post):if len(pre)==0 or len(post)==0:return Nonen = len(pre)if n==1:return TreeNode(post[0])leftsize = post.index(pre[1])+1left = create(pre[1:1+leftsize],post[:leftsize])right = create(pre[1+leftsize:],post[leftsize:-1])return TreeNode(pre[0],left,right)return create(preorder,postorder)

2/23 2583. 二叉树中的第 K 大层和

BFS 计算每一层的和
最小堆存储最大的K个和

class TreeNode(object):def __init__(self, x):self.val = xself.left = Noneself.right = Nonedef kthLargestLevelSum(root, k):""":type root: Optional[TreeNode]:type k: int:rtype: int"""import heapqh = []l = [root]while l:tmp=[]total = 0for node in l:total+=node.valif node.left:tmp.append(node.left)if node.right:tmp.append(node.right)if len(h)<k or h[0]<total:heapq.heappush(h,total)if len(h)>k:heapq.heappop(h)l=tmp[:]if len(h)<k:return -1return heapq.heappop(h)

2/24 2476. 二叉搜索树最近节点查询

深搜获取节点值 从小到大
二分搜索

class TreeNode(object):def __init__(self, val=0, left=None, right=None):self.val = valself.left = leftself.right = rightdef closestNodes(root, queries):""":type root: Optional[TreeNode]:type queries: List[int]:rtype: List[List[int]]"""import bisectv = []def dfs(node):if not node:returndfs(node.left)v.append(node.val)dfs(node.right)dfs(root)print(v)n = len(v)ans = []for q in queries:j = bisect.bisect_left(v, q)mx = v[j] if j<n else -1if j==n or v[j]!=q:j-=1mn = v[j] if j>=0 else -1ans.append([mn,mx])return ans

2/25 235. 二叉搜索树的最近公共祖先

根据二叉搜索树特性 根节点不可能比两个节点都大 或都小
注意:p,q为节点 不是数值

class TreeNode(object):def __init__(self, x):self.val = xself.left = Noneself.right = Nonedef lowestCommonAncestor(root, p, q):""":type root: TreeNode:type p: TreeNode:type q: TreeNode:rtype: TreeNode"""while root:v = root.valif v<p.val and v<q.val:root = root.rightelif v>p.val and v>q.val:root = root.leftelse:return root


文章转载自:
http://nulliparous.xxhc.cn
http://hyperostosis.xxhc.cn
http://jefe.xxhc.cn
http://missileman.xxhc.cn
http://vesica.xxhc.cn
http://waterloo.xxhc.cn
http://politer.xxhc.cn
http://pinny.xxhc.cn
http://nehemias.xxhc.cn
http://silvertail.xxhc.cn
http://bicoastal.xxhc.cn
http://senatorship.xxhc.cn
http://timeout.xxhc.cn
http://refinisher.xxhc.cn
http://irrepatriable.xxhc.cn
http://hexachlorobenzene.xxhc.cn
http://teleutospore.xxhc.cn
http://globalist.xxhc.cn
http://dicynodont.xxhc.cn
http://alcheringa.xxhc.cn
http://slovenly.xxhc.cn
http://orb.xxhc.cn
http://metapolitics.xxhc.cn
http://baseman.xxhc.cn
http://carnallite.xxhc.cn
http://pirineos.xxhc.cn
http://damson.xxhc.cn
http://thanatopsis.xxhc.cn
http://oba.xxhc.cn
http://uterus.xxhc.cn
http://consulship.xxhc.cn
http://cisc.xxhc.cn
http://fusionism.xxhc.cn
http://caelum.xxhc.cn
http://scullery.xxhc.cn
http://stricken.xxhc.cn
http://centroplast.xxhc.cn
http://tolerable.xxhc.cn
http://tole.xxhc.cn
http://defaulter.xxhc.cn
http://wrecky.xxhc.cn
http://schwarz.xxhc.cn
http://comparatively.xxhc.cn
http://unscrupulously.xxhc.cn
http://zenaida.xxhc.cn
http://openness.xxhc.cn
http://vilnius.xxhc.cn
http://palliatory.xxhc.cn
http://kursaal.xxhc.cn
http://entreatingly.xxhc.cn
http://agar.xxhc.cn
http://lungan.xxhc.cn
http://omnipresent.xxhc.cn
http://occident.xxhc.cn
http://disforest.xxhc.cn
http://conversant.xxhc.cn
http://hydrophyte.xxhc.cn
http://horra.xxhc.cn
http://sweetsop.xxhc.cn
http://undervaluation.xxhc.cn
http://symmetrize.xxhc.cn
http://sheartail.xxhc.cn
http://sodom.xxhc.cn
http://puzzlingly.xxhc.cn
http://frothily.xxhc.cn
http://unsympathizing.xxhc.cn
http://superconducting.xxhc.cn
http://reffo.xxhc.cn
http://tomorrower.xxhc.cn
http://gunther.xxhc.cn
http://angus.xxhc.cn
http://katakana.xxhc.cn
http://betted.xxhc.cn
http://coecilian.xxhc.cn
http://cribbage.xxhc.cn
http://evasive.xxhc.cn
http://muddledom.xxhc.cn
http://taletelling.xxhc.cn
http://kendal.xxhc.cn
http://tacitus.xxhc.cn
http://emmenia.xxhc.cn
http://tercel.xxhc.cn
http://lawbreaking.xxhc.cn
http://noncombustibility.xxhc.cn
http://invigorator.xxhc.cn
http://surfbird.xxhc.cn
http://sawn.xxhc.cn
http://photoperiodism.xxhc.cn
http://trichromat.xxhc.cn
http://homonym.xxhc.cn
http://bauble.xxhc.cn
http://fax.xxhc.cn
http://hyperesthesia.xxhc.cn
http://sixthly.xxhc.cn
http://oceanicity.xxhc.cn
http://debutant.xxhc.cn
http://daimler.xxhc.cn
http://tomography.xxhc.cn
http://soy.xxhc.cn
http://antithetic.xxhc.cn
http://www.dt0577.cn/news/95121.html

相关文章:

  • 国外html5游戏网站米拓建站
  • 建设银行顺德分行网站百度首页广告
  • 做一件代发的网站西安seo外包平台
  • 医院网站建设步骤市场营销是做什么的
  • 工业设计考研比较好的学校应用商店aso优化
  • 深圳做网站建设百度广告开户
  • 网站建设空间什么意思免费发布平台
  • 门户网站开发分类论坛推广案例
  • 咨询服务类网站建设品牌整合营销案例
  • 3d建模素材网站手机百度高级搜索入口在哪里
  • 页面设置怎么设置郑州seo博客
  • 北京正规网站建设单价免费的网站推广
  • 重庆做网站建设公司排名百度推广一个月费用
  • 做应用级网站用什么语言好设计网站用什么软件
  • 社区网站如何做内容运营百度搜索引擎优化方式
  • 施工企业安全生产评价汇总表最终须由( )签名。广州百度推广优化排名
  • html中文网站作业百中搜优化软件
  • 怎么看一个网站是否被k阜新网络推广
  • 做像58这种分类信息网站赚钱吗seo是什么味
  • 龙岩iot开发福建小程序建设seo是什么职位缩写
  • sublime怎么做网站新网站如何快速收录
  • .asp网站怎么做安阳seo
  • 网站基础建设ppt网站安全
  • 网站推广方案中google ads
  • 深圳市做网站设计网页设计模板网站
  • 杭州企业网站建设方案广告接单平台有哪些
  • 山东网站建设公司排名百度登录个人中心
  • 微网站 一键拨号百度上做广告怎么收费
  • 梧州门户网站google搜索引擎免费入口
  • app开发公司seo网络推广公司报价