Graph
文章平均质量分 83
flyatcmu
这个作者很懒,什么都没留下…
展开
-
Valid Arrangement of Pairs
You are given a0-indexed2D integer arraypairswherepairs[i] = [starti, endi]. An arrangement ofpairsisvalidif for every indexiwhere1 <= i < pairs.length, we haveendi-1== starti.Returnanyvalid arrangement ofpairs.Note:The inputs w...原创 2021-12-06 09:18:45 · 220 阅读 · 0 评论 -
Shortest Bridge
In a given 2D binary arrayA, there are two islands. (An island is a 4-directionally connected group of1s not connected to any other 1s.)Now, we may change0s to1s so as to connect the two islands together to form 1 island.Return the smallest number...原创 2020-06-07 08:08:00 · 204 阅读 · 0 评论 -
Evaluate Division
Equations are given in the formatA / B = k, whereAandBare variables represented as strings, andkis a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return-1.0.Example:Givena / b = 2.0,...原创 2020-06-07 06:58:10 · 162 阅读 · 0 评论 -
Tree Diameter
Given an undirected tree, returnits diameter: the number ofedgesin a longest path in that tree.The tree is given as an arrayofedgeswhereedges[i] = [u, v]is a bidirectional edge between nodesuandv. Each node haslabels in the set{0, 1, ..., e...原创 2020-05-12 06:48:23 · 411 阅读 · 0 评论 -
Minimum Time to Collect All Apples in a Tree
Given an undirected tree consisting ofnvertices numbered from 0 ton-1, which has some apples in theirvertices. You spend 1 second to walk over oneedge of the tree.Return the minimum time in secondsyou have to spendin order to collect all apples in ...原创 2020-05-11 01:12:12 · 237 阅读 · 0 评论 -
Critical Connections in a Network
There arenservers numbered from0ton-1connected byundirected server-to-serverconnectionsforming a network whereconnections[i] = [a, b]represents a connection between serversaandb. Any ser...原创 2020-02-29 13:32:19 · 654 阅读 · 0 评论 -
Is Graph Bipartite
Given an undirectedgraph, returntrueif and only if it is bipartite.Recall that a graph isbipartiteif we can split it's set of nodes into two independentsubsets A and B such that every edge in ...原创 2020-02-21 15:24:03 · 257 阅读 · 0 评论 -
Closest Leaf in a Binary Tree
Input:root = [1,2,3,4,null,null,null,5,null,6], k = 2Diagram of binary tree: 1 / \ 2 3 / 4 / 5 / 6Output: 3Expl...原创 2020-02-20 16:00:11 · 147 阅读 · 0 评论 -
Course Schedule II
There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a...原创 2016-09-02 13:44:36 · 286 阅读 · 0 评论 -
Dijkstra算法总结
1.如何建立图2. BFS3. DFS原创 2020-01-19 07:30:08 · 1492 阅读 · 0 评论 -
Course Schedule
There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a...原创 2016-09-02 13:14:43 · 396 阅读 · 0 评论 -
Reconstruct Itinerary
Given a list of airline tickets represented by pairs of departure and arrival airports[from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs fromJFK. Thus, the ...原创 2016-10-10 08:58:54 · 465 阅读 · 0 评论 -
Clone graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each nod...原创 2014-12-13 12:48:28 · 576 阅读 · 0 评论