leetcode.cn 2023-06-18
🟡1254.number-of-closed-islands
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡1254.number-of-closed-islands
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
number-of-closed-islands
二维矩阵 grid 由 0 (土地)和 1 (水)组成。岛是由最大的4个方向连通的 0 组成的群,封闭岛是一个 完全 由1包围(左、上、右、下)的岛。 请返回 封闭岛屿 的数目。 示例 1: 输入:grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0],[1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0]] 输出:2 解释: 灰色区域的岛屿是封闭岛屿,因为这座岛屿完全被水域包围(即被 1 区域包围)。 示例 2: 输入:grid…
leetcode.cn 2023-06-22
🟡面试题 16.19.pond-sizes-lcci
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
🟡面试题 16.19.pond-sizes-lcci
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #matrix
Telegraph
pond-sizes-lcci
你有一个用于表示一片土地的整数矩阵land,该矩阵中每个点的值代表对应地点的海拔高度。若值为0则表示水域。由垂直、水平或对角连接的水域为池塘。池塘的大小是指相连接的水域的个数。编写一个方法来计算矩阵中所有池塘的大小,返回值需要从小到大排序。 示例: 输入: [ [0,2,1,0], [0,1,0,1], [1,1,0,1], [0,1,0,1] ] 输出: [1,2,4] 提示: 0 < len(land) <= 1000 0 < len(land[i]) <= 1000
leetcode.com 2023-06-30
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
🔴1970.last-day-where-you-can-still-cross
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #binary_search #matrix
Telegraph
last-day-where-you-can-still-cross
There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively. Initially on day 0, the entire matrix is land. However, each day a…
leetcode.com 2023-08-19
🔴1489.find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
🏷️ Tags
#union_find #graph #minimum_spanning_tree #sorting #strongly_connected_component
🔴1489.find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
🏷️ Tags
#union_find #graph #minimum_spanning_tree #sorting #strongly_connected_component
Telegraph
find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of…
leetcode.cn 2023-08-24
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
🟡1267.count-servers-that-communicate
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #array #counting #matrix
Telegraph
count-servers-that-communicate
这里有一幅服务器分布图,服务器的位置标识在 m * n 的整数矩阵网格 grid 中,1 表示单元格上有服务器,0 表示没有。 如果两台服务器位于同一行或者同一列,我们就认为它们之间可以进行通信。 请你统计并返回能够与至少一台其他服务器进行通信的服务器的数量。 示例 1: 输入:grid = [[1,0],[0,1]] 输出:0 解释:没有一台服务器能与其他服务器进行通信。 示例 2: 输入:grid = [[1,0],[1,1]] 输出:3 解释:所有这些服务器都至少可以与一台别的服务器进行通信。…