Avatar

Organizations

8 results for 深度优先搜索
  • 给定一个  m x n 整数矩阵  matrix ,找出其中 最长递增路径 的长度。

    对于每个单元格,你可以往上,下,左,右四个方向移动。 你 不能对角线 方向上移动或移动到 边界外(即不允许环绕)。

  • 力扣数据中心有  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 from 0 to n - 1, and an array of n - 1 edges where edges[i] = [ai, bi] indicates that there is an undirected edge between the two nodes ai and bi in the tree, you can choose any node of the tree as the root. When you select a node x as the root, the result tree has height h. 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

  • 听说最近两斑点的奶牛最受欢迎,约翰立即购进了一批两斑点牛。

    不幸的是,时尚潮流往往变化很快,当前最受欢迎的牛变成了一斑点牛。

    约翰希望通过给每头奶牛涂色,使得它们身上的两个斑点能够合为一个斑点,让它们能够更加时尚。

  • 给出二叉 搜索 树的根节点,该树的节点值各不相同,请你将其转换为累加树(Greater Sum Tree),使每个节点 node  的新值等于原树中大于或等于  node.val  的值之和。

  • 给你一个 不含重复 单词的字符串数组 words ,请你找出并返回 words 中的所有 连接词

    连接词 定义为:一个完全由给定数组中的至少两个较短单词组成的字符串。

  • 如果一个正整数,其各个数位上的数字均满足要么是 0,要么是 1,则称该数字为 01 数。

    例如,1 和 10 都是 01 数。

    给定一个整数 n。

    请你计算,1∼n 中有多少个 01 数。