leetcode.com 2025-12-31
🔴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.cn 2026-01-06
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
maximum-level-sum-of-a-binary-tree
给你一个二叉树的根节点 root。设根节点位于二叉树的第 1 层,而根节点的子节点位于第 2 层,依此类推。 返回总和 最大 的那一层的层号 x。如果有多层的总和一样大,返回其中 最小 的层号 x。 示例 1: 输入:root = [1,7,0,7,-8,null,null] 输出:2 解释: 第 1 层各元素之和为 1, 第 2 层各元素之和为 7 + 0 = 7, 第 3 层各元素之和为 7 + -8 = -1, 所以我们返回第 2 层的层号,它的层内元素之和最大。 示例 2: 输入:root =…
leetcode.com 2026-01-06
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡1161.maximum-level-sum-of-a-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
maximum-level-sum-of-a-binary-tree
Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all the values of nodes at level x is maximal. Example 1: Input: root = [1,7,0,7,-8,null,null] Output:…
leetcode.cn 2026-01-07
🟡1339.maximum-product-of-splitted-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡1339.maximum-product-of-splitted-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
maximum-product-of-splitted-binary-tree
给你一棵二叉树,它的根为 root 。请你删除 1 条边,使二叉树分裂成两棵子树,且它们子树和的乘积尽可能大。 由于答案可能会很大,请你将结果对 10^9 + 7 取模后再返回。 示例 1: 输入:root = [1,2,3,4,5,6] 输出:110 解释:删除红色的边,得到 2 棵子树,和分别为 11 和 10 。它们的乘积是 110 (11*10) 示例 2: 输入:root = [1,null,2,3,4,null,null,5,6] 输出:90 解释:移除红色的边,得到 2 棵子树,和分别是…
leetcode.com 2026-01-07
🟡1339.maximum-product-of-splitted-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡1339.maximum-product-of-splitted-binary-tree
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
maximum-product-of-splitted-binary-tree
Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized. Return the maximum product of the sums of the two subtrees. Since the answer may be too large, return…
leetcode.cn 2026-01-09
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
smallest-subtree-with-all-the-deepest-nodes
给定一个根为 root 的二叉树,每个节点的深度是 该节点到根的最短距离 。 返回包含原始树中所有 最深节点 的 最小子树 。 如果一个节点在 整个树 的任意节点之间具有最大的深度,则该节点是 最深的 。 一个节点的 子树 是该节点加上它的所有后代的集合。 示例 1: 输入:root = [3,5,1,6,2,0,8,null,null,7,4] 输出:[2,7,4] 解释: 我们返回值为 2 的节点,在图中用黄色标记。 在图中用蓝色标记的是树的最深的节点。 注意,节点 5、3 和 2 包含树中最深的节点,但节点…
leetcode.com 2026-01-09
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡865.smallest-subtree-with-all-the-deepest-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
smallest-subtree-with-all-the-deepest-nodes
Given the root of a binary tree, the depth of each node is the shortest distance to the root. Return the smallest subtree such that it contains all the deepest nodes in the original tree. A node is called the deepest if it has the largest depth possible among…
leetcode.cn 2026-01-10
🟡712.minimum-ascii-delete-sum-for-two-strings
🏷️ Tags
#string #dynamic_programming
🟡712.minimum-ascii-delete-sum-for-two-strings
🏷️ Tags
#string #dynamic_programming
Telegraph
minimum-ascii-delete-sum-for-two-strings
给定两个字符串s1 和 s2,返回 使两个字符串相等所需删除字符的 ASCII 值的最小和 。 示例 1: 输入: s1 = "sea", s2 = "eat" 输出: 231 解释: 在 "sea" 中删除 "s" 并将 "s" 的值(115)加入总和。 在 "eat" 中删除 "t" 并将 116 加入总和。 结束时,两个字符串相等,115 + 116 = 231 就是符合条件的最小和。 示例 2: 输入: s1 = "delete", s2 = "leet" 输出: 403 解释: 在 "delete"…
leetcode.com 2026-01-10
🟡712.minimum-ascii-delete-sum-for-two-strings
🏷️ Tags
#string #dynamic_programming
🟡712.minimum-ascii-delete-sum-for-two-strings
🏷️ Tags
#string #dynamic_programming
Telegraph
minimum-ascii-delete-sum-for-two-strings
Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Input: s1 = "sea", s2 = "eat" Output: 231 Explanation: Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum. Deleting "t"…