leetcode.com 2023-08-09
🟡2616.minimize-the-maximum-difference-of-pairs
🏷️ Tags
#greedy #array #binary_search
🟡2616.minimize-the-maximum-difference-of-pairs
🏷️ Tags
#greedy #array #binary_search
Telegraph
minimize-the-maximum-difference-of-pairs
You are given a 0-indexed integer array nums and an integer p. Find p pairs of indices of nums such that the maximum difference amongst all the pairs is minimized. Also, ensure no index appears more than once amongst the p pairs. Note that for a pair of elements…
leetcode.cn 2023-08-12
🔴23.merge-k-sorted-lists
🏷️ Tags
#linked_list #divide_and_conquer #heap_priority_queue #merge_sort
🔴23.merge-k-sorted-lists
🏷️ Tags
#linked_list #divide_and_conquer #heap_priority_queue #merge_sort
Telegraph
merge-k-sorted-lists
给你一个链表数组,每个链表都已经按升序排列。 请你将所有链表合并到一个升序链表中,返回合并后的链表。 示例 1: 输入:lists = [[1,4,5],[1,3,4],[2,6]] 输出:[1,1,2,3,4,4,5,6] 解释:链表数组如下: [ 1->4->5, 1->3->4, 2->6 ] 将它们合并到一个有序链表中得到。 1->1->2->3->4->4->5->6 示例 2: 输入:lists = [] 输出:[] 示例 3: 输入:lists = [[]] 输出:[] 提示:
leetcode.com 2023-08-13
🟡2369.check-if-there-is-a-valid-partition-for-the-array
🏷️ Tags
#array #dynamic_programming
🟡2369.check-if-there-is-a-valid-partition-for-the-array
🏷️ Tags
#array #dynamic_programming
Telegraph
check-if-there-is-a-valid-partition-for-the-array
You are given a 0-indexed integer array nums. You have to partition the array into one or more contiguous subarrays. We call a partition of the array valid if each of the obtained subarrays satisfies one of the following conditions:
leetcode.cn 2023-08-14
🟢617.merge-two-binary-trees
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟢617.merge-two-binary-trees
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
merge-two-binary-trees
给你两棵二叉树: root1 和 root2 。 想象一下,当你将其中一棵覆盖到另一棵之上时,两棵树上的一些节点将会重叠(而另一些不会)。你需要将这两棵树合并成一棵新二叉树。合并的规则是:如果两个节点重叠,那么将这两个节点的值相加作为合并后节点的新值;否则,不为 null 的节点将直接作为新二叉树的节点。 返回合并后的二叉树。 注意: 合并过程必须从两个树的根节点开始。 示例 1: 输入:root1 = [1,3,2,5], root2 = [2,1,3,null,4,null,7] 输出:[3,4…
leetcode.com 2023-08-14
🟡215.kth-largest-element-in-an-array
🏷️ Tags
#array #divide_and_conquer #quickselect #sorting #heap_priority_queue
🟡215.kth-largest-element-in-an-array
🏷️ Tags
#array #divide_and_conquer #quickselect #sorting #heap_priority_queue
Telegraph
kth-largest-element-in-an-array
Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Can you solve it without sorting? Example 1: Input: nums = [3,2,1,5,6,4]…
leetcode.cn 2023-08-16
🟢2682.find-the-losers-of-the-circular-game
🏷️ Tags
#array #hash_table #simulation
🟢2682.find-the-losers-of-the-circular-game
🏷️ Tags
#array #hash_table #simulation
Telegraph
find-the-losers-of-the-circular-game
n 个朋友在玩游戏。这些朋友坐成一个圈,按 顺时针方向 从 1 到 n 编号。从第 i 个朋友的位置开始顺时针移动 1 步会到达第 (i + 1) 个朋友的位置(1 <= i < n),而从第 n 个朋友的位置开始顺时针移动 1 步会回到第 1 个朋友的位置。 游戏规则如下: 第 1 个朋友接球。
leetcode.com 2023-08-16
🔴239.sliding-window-maximum
🏷️ Tags
#queue #array #sliding_window #monotonic_queue #heap_priority_queue
🔴239.sliding-window-maximum
🏷️ Tags
#queue #array #sliding_window #monotonic_queue #heap_priority_queue
Telegraph
sliding-window-maximum
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return…
leetcode.cn 2023-08-17
🔴1444.number-of-ways-of-cutting-a-pizza
🏷️ Tags
#memoization #array #dynamic_programming #matrix
🔴1444.number-of-ways-of-cutting-a-pizza
🏷️ Tags
#memoization #array #dynamic_programming #matrix
Telegraph
number-of-ways-of-cutting-a-pizza
给你一个 rows x cols 大小的矩形披萨和一个整数 k ,矩形包含两种字符: 'A' (表示苹果)和 '.' (表示空白格子)。你需要切披萨 k-1 次,得到 k 块披萨并送给别人。 切披萨的每一刀,先要选择是向垂直还是水平方向切,再在矩形的边界上选一个切的位置,将披萨一分为二。如果垂直地切披萨,那么需要把左边的部分送给一个人,如果水平地切,那么需要把上面的部分送给一个人。在切完最后一刀后,需要把剩下来的一块送给最后一个人。 请你返回确保每一块披萨包含 至少 一个苹果的切披萨方案数。由于答案可能是个很大的数字,请你返回它对…
leetcode.com 2023-08-17
🟡542.01-matrix
🏷️ Tags
#breadth_first_search #array #dynamic_programming #matrix
🟡542.01-matrix
🏷️ Tags
#breadth_first_search #array #dynamic_programming #matrix
Telegraph
01-matrix
Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: mat = [[0,0,0],[0,1,0],[0,0,0]] Output: [[0,0,0],[0,1,0],[0,0,0]] Example 2: Input: mat = [[0,0,0],[0,1…