
Dijkstra
文章平均质量分 87
flyatcmu
这个作者很懒,什么都没留下…
展开
-
Min Cost to Connect All Points
You are given an arraypointsrepresenting integer coordinates of some points on a 2D-plane, wherepoints[i] = [xi, yi].The cost of connecting two points[xi, yi]and[xj, yj]is themanhattan distancebetween them:|xi- xj| + |yi- yj|, where|val|den...原创 2020-09-14 05:31:08 · 397 阅读 · 0 评论 -
Connecting Cities With Minimum Cost
There areNcities numbered from 1 toN.You are givenconnections, where eachconnections[i] = [city1, city2, cost]represents the cost to connectcity1andcity2together. (Aconnectionis bidirec...原创 2020-03-29 10:14:52 · 408 阅读 · 0 评论 -
Path with Maximum Probability
You are given an undirected weighted graph ofnnodes (0-indexed), represented by an edge list whereedges[i] = [a, b]is an undirected edge connecting the nodesaandbwith a probability of success of traversing that edgesuccProb[i].Given two nodesst...原创 2020-07-12 13:07:06 · 326 阅读 · 0 评论 -
BFS 到 Level Order traverse 到 UnionFind 到 Topological Sort 到 Dijkstra 思路总结
BFSLevel OrderTopological SortDijkstra原创 2020-07-01 09:44:21 · 975 阅读 · 0 评论 -
Minimum Cost to Make at Least One Valid Path in a Grid
Given amxngrid. Each cell of thegridhas a sign pointing to the next cell you should visit if you are currently in this cell. The sign ofgrid[i][j]can be:1which means go to the cell to the right. (i.e go fromgrid[i][j]togrid[i][j + 1]) 2whic...原创 2020-06-29 12:24:48 · 250 阅读 · 0 评论 -
Swim in Rising Water
On an N x Ngrid, each squaregrid[i][j]represents the elevation at that point(i,j).Now rain starts to fall. At timet, the depth of the water everywhere ist. You can swim from a square to another 4-directionally adjacent square if and only if the ele...原创 2020-05-26 11:24:15 · 279 阅读 · 0 评论 -
Find the Kth Smallest Sum of a Matrix With Sorted Rows
You are given anm* nmatrix,mat, and an integerk,whichhas its rows sorted in non-decreasingorder.You are allowed to choose exactly 1 element from each row to form an array.Return the Kthsma...原创 2020-05-03 14:21:05 · 338 阅读 · 0 评论 -
Path With Maximum Minimum Value
Given amatrix of integersAwithRrows andCcolumns, findthemaximumscoreof a path starting at[0,0]and ending at[R-1,C-1].Thescoreof a path is theminimumvalue in that path. For example...原创 2020-04-29 11:14:14 · 422 阅读 · 0 评论 -
Find the City With the Smallest Number of Neighbors at a Threshold Distance
There arencities numbered from0ton-1. Given the arrayedgeswhereedges[i] = [fromi, toi, weighti]represents a bidirectional and weighted edge between citiesfromiandtoi, and given the integer...原创 2020-02-28 16:04:31 · 418 阅读 · 1 评论 -
Network Delay Time
Giventimes, a list of travel times asdirectededgestimes[i] = (u, v, w), whereuis the source node,vis the target node, andwis the time it takes for a signal to travel from source to target....原创 2020-02-18 08:05:57 · 319 阅读 · 0 评论 -
Dijkstra算法总结
1.如何建立图2. BFS3. DFS原创 2020-01-19 07:30:08 · 1539 阅读 · 0 评论 -
Cheapest Flights Within K Stops
Example 1:Input: n = 3, edges = [[0,1,100],[1,2,100],[0,2,500]]src = 0, dst = 2, k = 1Output: 200Explanation: The graph looks like this:思路:就是要弄明白graph怎么建立,pq里面存什么,怎么进行搜索;graph: HashMap<...原创 2020-02-18 07:35:32 · 417 阅读 · 0 评论 -
The Maze II
Input 1: a maze represented by a 2D array0 0 1 0 00 0 0 0 00 0 0 1 01 1 0 1 10 0 0 0 0Input 2: start coordinate (rowStart, colStart) = (0, 4)Input 3: destination coordinate (rowDest, colDest...原创 2020-02-18 05:12:57 · 257 阅读 · 0 评论