leetcode.cn 2023-05-28
🔴1439.find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows
🏷️ Tags
#array #binary_search #matrix #heap_priority_queue
🔴1439.find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows
🏷️ Tags
#array #binary_search #matrix #heap_priority_queue
Telegraph
find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows
给你一个 m * n 的矩阵 mat,以及一个整数 k ,矩阵中的每一行都以非递减的顺序排列。 你可以从每一行中选出 1 个元素形成一个数组。返回所有可能数组中的第 k 个 最小 数组和。 示例 1: 输入:mat = [[1,3,11],[2,4,6]], k = 5 输出:7 解释:从每一行中选出一个元素,前 k 个和最小的数组分别是: [1,2], [1,4], [3,2], [3,4], [1,6]。其中第 5 个的和是 7 。 示例 2: 输入:mat = [[1,3,11],[2,4,6]]…
leetcode.cn 2023-05-29
🟢2455.average-value-of-even-numbers-that-are-divisible-by-three
🏷️ Tags
#array #math
🟢2455.average-value-of-even-numbers-that-are-divisible-by-three
🏷️ Tags
#array #math
Telegraph
average-value-of-even-numbers-that-are-divisible-by-three
给你一个由正整数组成的整数数组 nums ,返回其中可被 3 整除的所有偶数的平均值。 注意:n 个元素的平均值等于 n 个元素 求和 再除以 n ,结果 向下取整 到最接近的整数。 示例 1: 输入:nums = [1,3,6,10,12,15] 输出:9 解释:6 和 12 是可以被 3 整除的偶数。(6 + 12) / 2 = 9 。 示例 2: 输入:nums = [1,2,4,7,10] 输出:0 解释:不存在满足题目要求的整数,所以返回 0 。 提示:
leetcode.cn 2023-05-30
🟡1110.delete-nodes-and-return-forest
🏷️ Tags
#tree #depth_first_search #array #hash_table #binary_tree
🟡1110.delete-nodes-and-return-forest
🏷️ Tags
#tree #depth_first_search #array #hash_table #binary_tree
Telegraph
delete-nodes-and-return-forest
给出二叉树的根节点 root,树上每个节点都有一个不同的值。 如果节点值在 to_delete 中出现,我们就把该节点从树上删去,最后得到一个森林(一些不相交的树构成的集合)。 返回森林中的每棵树。你可以按任意顺序组织答案。 示例 1: 输入:root = [1,2,3,4,5,6,7], to_delete = [3,5] 输出:[[1,2,null,4],[6],[7]] 示例 2: 输入:root = [1,2,4,null,3], to_delete = [3] 输出:[[1,2,4]] …
leetcode.cn 2023-05-31
🟡1130.minimum-cost-tree-from-leaf-values
🏷️ Tags
#stack #greedy #array #dynamic_programming #monotonic_stack
🟡1130.minimum-cost-tree-from-leaf-values
🏷️ Tags
#stack #greedy #array #dynamic_programming #monotonic_stack
Telegraph
minimum-cost-tree-from-leaf-values
给你一个正整数数组 arr,考虑所有满足以下条件的二叉树:
leetcode.com 2023-06-01
🟡1091.shortest-path-in-binary-matrix
🏷️ Tags
#breadth_first_search #array #matrix
🟡1091.shortest-path-in-binary-matrix
🏷️ Tags
#breadth_first_search #array #matrix
Telegraph
shortest-path-in-binary-matrix
Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1. A clear path in a binary matrix is a path from the top-left cell (i.e., (0, 0)) to the bottom-right cell (i.e., (n - 1, n…
leetcode.com 2023-06-02
🟡2101.detonate-the-maximum-bombs
🏷️ Tags
#depth_first_search #breadth_first_search #graph #geometry #array #math
🟡2101.detonate-the-maximum-bombs
🏷️ Tags
#depth_first_search #breadth_first_search #graph #geometry #array #math
Telegraph
detonate-the-maximum-bombs
You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb. The bombs are represented by a 0-indexed 2D integer array bombs where…
leetcode.cn 2023-06-03
🟡1156.swap-for-longest-repeated-character-substring
🏷️ Tags
#hash_table #string #sliding_window
🟡1156.swap-for-longest-repeated-character-substring
🏷️ Tags
#hash_table #string #sliding_window
Telegraph
swap-for-longest-repeated-character-substring
如果字符串中的所有字符都相同,那么这个字符串是单字符重复的字符串。 给你一个字符串 text,你只能交换其中两个字符一次或者什么都不做,然后得到一些单字符重复的子串。返回其中最长的子串的长度。 示例 1: 输入:text = "ababa" 输出:3 示例 2: 输入:text = "aaabaaa" 输出:6 示例 3: 输入:text = "aaabbaaa" 输出:4 示例 4: 输入:text = "aaaaa" 输出:5 示例 5: 输入:text = "abcdef" 输出:1 提示:
leetcode.com 2023-06-03
🟡1376.time-needed-to-inform-all-employees
🏷️ Tags
#tree #depth_first_search #breadth_first_search
🟡1376.time-needed-to-inform-all-employees
🏷️ Tags
#tree #depth_first_search #breadth_first_search
Telegraph
time-needed-to-inform-all-employees
A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID. Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID]…
leetcode.cn 2023-06-04
🔴2699.modify-graph-edge-weights
🏷️ Tags
#graph #shortest_path #heap_priority_queue
🔴2699.modify-graph-edge-weights
🏷️ Tags
#graph #shortest_path #heap_priority_queue
Telegraph
modify-graph-edge-weights
给你一个 n 个节点的 无向带权连通 图,节点编号为 0 到 n - 1 ,再给你一个整数数组 edges ,其中 edges[i] = [ai, bi, wi] 表示节点 ai 和 bi 之间有一条边权为 wi 的边。 部分边的边权为 -1(wi = -1),其他边的边权都为 正 数(wi > 0)。 你需要将所有边权为 -1 的边都修改为范围 [1, 2 * 109] 中的 正整数 ,使得从节点 source 到节点 destination 的 最短距离 为整数 target 。如果有 多种 修改方案可以使 source…
leetcode.com 2023-06-04
🟡547.number-of-provinces
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
🟡547.number-of-provinces
🏷️ Tags
#depth_first_search #breadth_first_search #union_find #graph
Telegraph
number-of-provinces
There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c. A province is a group of directly or indirectly…
leetcode.cn 2023-06-04
🟢2465.number-of-distinct-averages
🏷️ Tags
#array #hash_table #two_pointers #sorting
🟢2465.number-of-distinct-averages
🏷️ Tags
#array #hash_table #two_pointers #sorting
Telegraph
number-of-distinct-averages
给你一个下标从 0 开始长度为 偶数 的整数数组 nums 。 只要 nums 不是 空数组,你就重复执行以下步骤: