leetcode.com 2023-07-15
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
Telegraph
maximum-number-of-events-that-can-be-attended-ii
You are given an array of events where events[i] = [startDayi, endDayi, valuei]. The ith event starts at startDayi and ends at endDayi, and if you attend this event, you will receive a value of valuei. You are also given an integer k which represents the…
leetcode.cn 2023-07-16
🔴834.sum-of-distances-in-tree
🏷️ Tags
#tree #depth_first_search #graph #dynamic_programming
🔴834.sum-of-distances-in-tree
🏷️ Tags
#tree #depth_first_search #graph #dynamic_programming
Telegraph
sum-of-distances-in-tree
给定一个无向、连通的树。树中有 n 个标记为 0...n-1 的节点以及 n-1 条边 。 给定整数 n 和数组 edges , edges[i] = [ai, bi]表示树中的节点 ai 和 bi 之间有一条边。 返回长度为 n 的数组 answer ,其中 answer[i] 是树中第 i 个节点与所有其他节点之间的距离之和。 示例 1: 输入: n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]] 输出: [8,12,6,10,10,10] 解释: 树如图所示。…
leetcode.com 2023-07-16
🔴1125.smallest-sufficient-team
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask
🔴1125.smallest-sufficient-team
🏷️ Tags
#bit_manipulation #array #dynamic_programming #bitmask
Telegraph
smallest-sufficient-team
In a project, you have a list of required skills req_skills, and a list of people. The ith person people[i] contains a list of skills that the person has. Consider a sufficient team: a set of people such that for every required skill in req_skills, there…
leetcode.cn 2023-07-18
🔴1851.minimum-interval-to-include-each-query
🏷️ Tags
#array #binary_search #sorting #line_sweep #heap_priority_queue
🔴1851.minimum-interval-to-include-each-query
🏷️ Tags
#array #binary_search #sorting #line_sweep #heap_priority_queue
Telegraph
minimum-interval-to-include-each-query
给你一个二维整数数组 intervals ,其中 intervals[i] = [lefti, righti] 表示第 i 个区间开始于 lefti 、结束于 righti(包含两侧取值,闭区间)。区间的 长度 定义为区间中包含的整数数目,更正式地表达是 righti - lefti + 1 。 再给你一个整数数组 queries 。第 j 个查询的答案是满足 lefti <= queries[j] <= righti 的 长度最小区间 i 的长度 。如果不存在这样的区间,那么答案是 -1 。 以数组形式返回对应查询的所有答案。…
leetcode.com 2023-07-19
🟡435.non-overlapping-intervals
🏷️ Tags
#greedy #array #dynamic_programming #sorting
🟡435.non-overlapping-intervals
🏷️ Tags
#greedy #array #dynamic_programming #sorting
Telegraph
non-overlapping-intervals
Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Example 1: Input: intervals = [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation:…
leetcode.cn 2023-07-20
🟡918.maximum-sum-circular-subarray
🏷️ Tags
#queue #array #divide_and_conquer #dynamic_programming #monotonic_queue
🟡918.maximum-sum-circular-subarray
🏷️ Tags
#queue #array #divide_and_conquer #dynamic_programming #monotonic_queue
Telegraph
maximum-sum-circular-subarray
给定一个长度为 n 的环形整数数组 nums ,返回 nums 的非空 子数组 的最大可能和 。 环形数组 意味着数组的末端将会与开头相连呈环状。形式上, nums[i] 的下一个元素是 nums[(i + 1) % n] , nums[i] 的前一个元素是 nums[(i - 1 + n) % n] 。 子数组 最多只能包含固定缓冲区 nums 中的每个元素一次。形式上,对于子数组 nums[i], nums[i + 1], ..., nums[j] ,不存在 i <= k1, k2 <= j 其中 k1…
leetcode.cn 2023-07-21
🔴1499.max-value-of-equation
🏷️ Tags
#queue #array #sliding_window #monotonic_queue #heap_priority_queue
🔴1499.max-value-of-equation
🏷️ Tags
#queue #array #sliding_window #monotonic_queue #heap_priority_queue
Telegraph
max-value-of-equation
给你一个数组 points 和一个整数 k 。数组中每个元素都表示二维平面上的点的坐标,并按照横坐标 x 的值从小到大排序。也就是说 points[i] = [xi, yi] ,并且在 1 <= i < j <= points.length 的前提下, xi < xj 总成立。 请你找出 yi + yj + |xi - xj| 的 最大值,其中 |xi - xj| <= k 且 1 <= i < j <= points.length。 题目测试数据保证至少存在一对能够满足 |xi - xj| <= k 的点。…
leetcode.com 2023-07-21
🟡673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
🟡673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
Telegraph
number-of-longest-increasing-subsequence
Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: Input: nums = [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequences are [1, 3, 4,…
leetcode.cn 2023-07-23
🔴42.trapping-rain-water
🏷️ Tags
#stack #array #two_pointers #dynamic_programming #monotonic_stack
🔴42.trapping-rain-water
🏷️ Tags
#stack #array #two_pointers #dynamic_programming #monotonic_stack
Telegraph
trapping-rain-water
给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 示例 1: 输入:height = [0,1,0,2,1,0,1,3,2,1,2,1] 输出:6 解释:上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 示例 2: 输入:height = [4,2,0,3,2,5] 输出:9 提示:
leetcode.com 2023-07-23
🟡894.all-possible-full-binary-trees
🏷️ Tags
#tree #recursion #memoization #dynamic_programming #binary_tree
🟡894.all-possible-full-binary-trees
🏷️ Tags
#tree #recursion #memoization #dynamic_programming #binary_tree
Telegraph
all-possible-full-binary-trees
Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0. Each element of the answer is the root node of one possible tree. You may return the final list of trees in any…
leetcode.cn 2023-07-25
🟡2208.minimum-operations-to-halve-array-sum
🏷️ Tags
#greedy #array #heap_priority_queue
🟡2208.minimum-operations-to-halve-array-sum
🏷️ Tags
#greedy #array #heap_priority_queue
Telegraph
minimum-operations-to-halve-array-sum
给你一个正整数数组 nums 。每一次操作中,你可以从 nums 中选择 任意 一个数并将它减小到 恰好 一半。(注意,在后续操作中你可以对减半过的数继续执行操作) 请你返回将 nums 数组和 至少 减少一半的 最少 操作数。 示例 1: 输入:nums = [5,19,8,1] 输出:3 解释:初始 nums 的和为 5 + 19 + 8 + 1 = 33 。 以下是将数组和减少至少一半的一种方法: 选择数字 19 并减小为 9.5 。 选择数字 9.5 并减小为 4.75 。 选择数字 8 并减小为…