• 2024-09-10代码随想录day 56 || 图论6
    Prim算法应用场景是主要是找到一个无向连通图的最小生成树,即连接所有节点且权重总和最小的树//prim三部曲//1,找到距离当前最小树最近节点//2,节点入树//3,更新mindist//更新树funcupdateMinDist(edges[][]int,nodeint){ for_,edge:=rangeedges{ ifed
  • 2024-08-13leetcode面试经典150题- 121. 买卖股票的最佳时机
    https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/description/?envType=study-plan-v2&envId=top-interview-150gopackageleetcode150import("testing")funcTestMaxProfit(t*testing.T){prices:=[]int{2,1,2,0,1}