• 2024-05-12Lowest Common Ancestor
    SourceGiventherootandtwonodesinaBinaryTree.Findthelowestcommonancestor(LCA)ofthetwonodes.Thelowestcommonancestoristhenodewithlargestdepthwhichistheancestorofbothnodes.Example4/\37
  • 2024-03-29最近公共祖先 (Lowest Common Ancestor)LCA
    最近公共祖先原文链接c++代码#include<bits/stdc++.h>usingnamespacestd;constexprintN=5E5+10;structedge{intto,next;//两个整型成员变量to和next。这个结构体表示了图中的一条边,其中to表示边的终点,//next表示下一条
  • 2023-12-12C++学习笔记八:极限和数学运算<limits><cmath>
    1)<limits>库:1.1源文档:https://en.cppreference.com/w/cpp/types/numeric_limits#include<limits> 1.2库函数:函数解释:对于一个浮点数,lowest表示最小的可表示的负数,min表示最小的可表示的接近0的数,max表示最大的可表示的正数对于一个有符号整数,min表示可以表示的最小的
  • 2023-11-19 python之numpy处理股票数据
    一概述Numpy是一个最重要的一个基于多维数组对象,即ndarray对象,该对象具有矢量算数运算能力和复杂的广播能力,可以执行一些科学计算。它的常用属性如下表所示:属性说明ndim数组的维度,如一维、二维、三维等shape数组的形状,如一个5行4列的数组,它的shape属性为(5,4)size数组元素的总个数
  • 2023-07-317.31
    今天仍然在整理pta的题目,还时挺慢的,今天整理到第40题了,下午的时候雨停了,去路上练了一会车,为科目三做准备#include<iostream>usingnamespacestd;intmain(){intn;cin>>n;doublesum=0;for(inti=0;i<n;i++){doublet;cin
  • 2023-03-01【一月一本技术书】-【算法图解-像小说一样有趣的算法入门书】- 2023-2月
    算法简介算法要么有速度,要么解决有趣的问题。二分法当有序的时候。就要想到二分法。范围缩小到只包含一个元素defbinary_serach(arr,target): left=0 right=
  • 2023-02-07235. Lowest Common Ancestor of a Binary Search Tree[Medium]
    235.LowestCommonAncestorofaBinarySearchTreeGivenabinarysearchtree(BST),findthelowestcommonancestor(LCA)nodeoftwogivennodesintheBST.
  • 2023-01-14[Typescript] Represent Generics at the Lowest Level
      Therearetwosolutionstothischallenge,bothwithdifferentwaysofrepresentingthegeneric.Solution1:Thefirstoptionisusing TConfig whichex
  • 2022-12-13狄克斯特拉算法实现
    最近学习《算法图解》,记录一下自己默写的狄克斯特拉算法,该算法用Python书写。graph={}infinity=float('inf')graph['start']={}graph['start']['a']=5graph['start'
  • 2022-12-05LeetCode: 236. Lowest Common Ancestor of a Binary Tree
    LeetCode:236.LowestCommonAncestorofaBinaryTree题目描述Givenabinarytree,findthelowestcommonancestor(LCA)oftwogivennodesinthetree.Accordi
  • 2022-11-27236. Lowest Common Ancestor of a Binary Tree
     给定一个二叉树和所要查找的两个节点,找到两个节点的最近公共父亲节点(LCA)。比如,节点5和1的LCA是3,节点5和4的LCA是5。classSolution{    publicTreeNodelowest
  • 2022-11-22Dijkstra Algorithm
    与BFS不同的是每条路径多了权重1.步骤:找到最便宜的节点,即可在最短时间内前往的节点对于该节点的邻居,检查是否有前往它们的更短路径,如果有,就更新其开销。重复这个过程,直到对
  • 2022-11-191106 Lowest Price in Supply Chain
    Asupplychainisanetworkofretailers(零售商),distributors(经销商),andsuppliers(供应商)--everyoneinvolvedinmovingaproductfromsuppliertocustomer.Star
  • 2022-11-04leetcode-1984-easy
    MinimumDifferenceBetweenHighestandLowestofKScoresYouaregivena0-indexedintegerarraynums,wherenums[i]representsthescoreoftheithstudent.
  • 2022-10-21算法 -Dijkstra算法
    以这个图为例,找到从起点到终点的耗时最短的路径(圆圈连线上的数字代表耗时)。graph={}graph["start"]={}graph["start"]["a"]=6graph["start"]["b"]=2graph["a"]={}graph["a
  • 2022-10-10leetcode 236. Lowest Common Ancestor of a Binary Tree 二叉树的最近公共祖先(中等)
    一、题目大意给定一个二叉树,找到该树中两个指定节点的最近公共祖先。百度百科中最近公共祖先的定义为:“对于有根树T的两个节点p、q,最近公共祖先表示为一个节点x,满
  • 2022-10-04leetcode 235. Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最近公共祖先(简单)
    一、题目大意给定一个二叉搜索树,找到该树中两个指定节点的最近公共祖先。百度百科中最近公共祖先的定义为:“对于有根树T的两个结点p、q,最近公共祖先表示为一个结点