leetcode.com 2023-08-06
🔴920.number-of-music-playlists
🏷️ Tags
#math #dynamic_programming #combinatorics
🔴920.number-of-music-playlists
🏷️ Tags
#math #dynamic_programming #combinatorics
Telegraph
number-of-music-playlists
Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that:
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 个朋友接球。