力扣数据中心有
n
台服务器,分别按从0
到n-1
的方式进行了编号。它们之间以「服务器到服务器」点对点的形式相互连接组成了一个内部集群,其中连接connections
是无向的。从形式上讲,connections[i] = [a, b]
表示服务器a
和b
之间形成连接。任何服务器都可以直接或者间接地通过网络到达任何其他服务器。「关键连接」 是在该集群中的重要连接,也就是说,假如我们将它移除,便会导致某些服务器无法访问其他服务器。
请你以任意顺序返回该集群内的所有 「关键连接」。
A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.
Given a tree of
n
nodes labelled from0
ton - 1
, and an array ofn - 1
edges
whereedges[i] = [ai, bi]
indicates that there is an undirected edge between the two nodesai
andbi
in the tree, you can choose any node of the tree as the root. When you select a nodex
as the root, the result tree has heighth
. Among all possible rooted trees, those with minimum height (i.e.min(h)
) are called minimum height trees (MHTs).Return a list of all MHTs’ root labels. You can return the answer in any order.
The height of a rooted tree is the number of edges on the longest downward path between the root and a leaf.
在一个 \(10^6 \times 10^6\) 的网格中,每个网格上方格的坐标为
(x, y)
。现在从源方格 \(source = [s_x, s_y]\) 开始出发,意图赶往目标方格 \(target = [t_x, t_y]\) 。数组
blocked
是封锁的方格列表,其中每个 \(blocked[i] = [x_i, y_i]\) 表示坐标为 \((x_i, y_i)\) 的方格是禁止通行的。每次移动,都可以走到网格中在四个方向上相邻的方格,只要该方格 不 在给出的封锁列表
blocked
上。同时,不允许走出网格。只有在可以通过一系列的移动从源方格
source
到达目标方格target
时才返回true
。否则,返回false
。听说最近两斑点的奶牛最受欢迎,约翰立即购进了一批两斑点牛。
不幸的是,时尚潮流往往变化很快,当前最受欢迎的牛变成了一斑点牛。
约翰希望通过给每头奶牛涂色,使得它们身上的两个斑点能够合为一个斑点,让它们能够更加时尚。