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 并减小为…
leetcode.com 2023-07-27
🔴2141.maximum-running-time-of-n-computers
🏷️ Tags
#greedy #array #binary_search #sorting
🔴2141.maximum-running-time-of-n-computers
🏷️ Tags
#greedy #array #binary_search #sorting
Telegraph
maximum-running-time-of-n-computers
You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries. Initially…
leetcode.cn 2023-07-28
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
Telegraph
parallel-courses-iii
给你一个整数 n ,表示有 n 节课,课程编号从 1 到 n 。同时给你一个二维整数数组 relations ,其中 relations[j] = [prevCoursej, nextCoursej] ,表示课程 prevCoursej 必须在课程 nextCoursej 之前 完成(先修课的关系)。同时给你一个下标从 0 开始的整数数组 time ,其中 time[i] 表示完成第 (i+1) 门课程需要花费的 月份 数。 请你根据以下规则算出完成所有课程所需要的 最少 月份数:
leetcode.com 2023-07-28
🟡486.predict-the-winner
🏷️ Tags
#recursion #array #math #dynamic_programming #game_theory
🟡486.predict-the-winner
🏷️ Tags
#recursion #array #math #dynamic_programming #game_theory
Telegraph
predict-the-winner
You are given an integer array nums. Two players are playing a game with this array: player 1 and player 2. Player 1 and player 2 take turns, with player 1 starting first. Both players start the game with a score of 0. At each turn, the player takes one of…