leetcode.com 2024-01-16
🟡380.insert-delete-getrandom-o1
🏷️ Tags
#design #array #hash_table #math #randomized
🟡380.insert-delete-getrandom-o1
🏷️ Tags
#design #array #hash_table #math #randomized
Telegraph
insert-delete-getrandom-o1
Implement the RandomizedSet class:
leetcode.cn 2024-01-17
🟢2744.find-maximum-number-of-string-pairs
🏷️ Tags
#array #hash_table #string #simulation
🟢2744.find-maximum-number-of-string-pairs
🏷️ Tags
#array #hash_table #string #simulation
Telegraph
find-maximum-number-of-string-pairs
给你一个下标从 0 开始的数组 words ,数组中包含 互不相同 的字符串。 如果字符串 words[i] 与字符串 words[j] 满足以下条件,我们称它们可以匹配:
leetcode.cn 2024-01-18
🟡2171.removing-minimum-number-of-magic-beans
🏷️ Tags
#array #prefix_sum #sorting
🟡2171.removing-minimum-number-of-magic-beans
🏷️ Tags
#array #prefix_sum #sorting
Telegraph
removing-minimum-number-of-magic-beans
给定一个 正整数 数组 beans ,其中每个整数表示一个袋子里装的魔法豆的数目。 请你从每个袋子中 拿出 一些豆子(也可以 不拿出),使得剩下的 非空 袋子中(即 至少还有一颗 魔法豆的袋子)魔法豆的数目 相等。一旦把魔法豆从袋子中取出,你不能再将它放到任何袋子中。 请返回你需要拿出魔法豆的 最少数目。 示例 1: 输入:beans = [4,1,6,5] 输出:4 解释: - 我们从有 1 个魔法豆的袋子中拿出 1 颗魔法豆。 剩下袋子中魔法豆的数目为:[4,0,6,5] - 然后我们从有 6 个魔法豆的袋子中拿出…
leetcode.cn 2024-01-19
🔴2809.minimum-time-to-make-array-sum-at-most-x
🏷️ Tags
#array #dynamic_programming #sorting
🔴2809.minimum-time-to-make-array-sum-at-most-x
🏷️ Tags
#array #dynamic_programming #sorting
Telegraph
minimum-time-to-make-array-sum-at-most-x
给你两个长度相等下标从 0 开始的整数数组 nums1 和 nums2 。每一秒,对于所有下标 0 <= i < nums1.length ,nums1[i] 的值都增加 nums2[i] 。操作 完成后 ,你可以进行如下操作:
leetcode.com 2024-01-20
🟡907.sum-of-subarray-minimums
🏷️ Tags
#stack #array #dynamic_programming #monotonic_stack
🟡907.sum-of-subarray-minimums
🏷️ Tags
#stack #array #dynamic_programming #monotonic_stack
Telegraph
sum-of-subarray-minimums
Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7. Example 1: Input: arr = [3,1,2,4] Output: 17 Explanation: Subarrays are [3]…
leetcode.cn 2024-01-21
🔴410.split-array-largest-sum
🏷️ Tags
#greedy #array #binary_search #dynamic_programming #prefix_sum
🔴410.split-array-largest-sum
🏷️ Tags
#greedy #array #binary_search #dynamic_programming #prefix_sum
Telegraph
split-array-largest-sum
给定一个非负整数数组 nums 和一个整数 k ,你需要将这个数组分成 k 个非空的连续子数组。 设计一个算法使得这 k 个子数组各自和的最大值最小。 示例 1: 输入:nums = [7,2,5,10,8], k = 2 输出:18 解释: 一共有四种方法将 nums 分割为 2 个子数组。 其中最好的方式是将其分为 [7,2,5] 和 [10,8] 。 因为此时这两个子数组各自的和的最大值为18,在所有情况中最小。 示例 2: 输入:nums = [1,2,3,4,5], k = 2 输出:9 示例…
leetcode.com 2024-01-23
🟡1239.maximum-length-of-a-concatenated-string-with-unique-characters
🏷️ Tags
#bit_manipulation #array #string #backtracking
🟡1239.maximum-length-of-a-concatenated-string-with-unique-characters
🏷️ Tags
#bit_manipulation #array #string #backtracking
Telegraph
maximum-length-of-a-concatenated-string-with-unique-characters
You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the maximum possible length of s. A subsequence is an array that can be derived from another array by deleting some…
leetcode.com 2024-01-24
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
pseudo-palindromic-paths-in-a-binary-tree
Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome. Return the number of pseudo-palindromic paths going from the…
leetcode.cn 2024-01-26
🔴2846.minimum-edge-weight-equilibrium-queries-in-a-tree
🏷️ Tags
#tree #graph #array #strongly_connected_component
🔴2846.minimum-edge-weight-equilibrium-queries-in-a-tree
🏷️ Tags
#tree #graph #array #strongly_connected_component
Telegraph
minimum-edge-weight-equilibrium-queries-in-a-tree
现有一棵由 n 个节点组成的无向树,节点按从 0 到 n - 1 编号。给你一个整数 n 和一个长度为 n - 1 的二维整数数组 edges ,其中 edges[i] = [ui, vi, wi] 表示树中存在一条位于节点 ui 和节点 vi 之间、权重为 wi 的边。 另给你一个长度为 m 的二维整数数组 queries ,其中 queries[i] = [ai, bi] 。对于每条查询,请你找出使从 ai 到 bi 路径上每条边的权重相等所需的 最小操作次数 。在一次操作中,你可以选择树上的任意一条边,并将其权重更改为任意值。…