全站内容
hard
1368. Minimum Cost to Make at Least One Valid Path in a Grid
#Problem Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be: 1 which means go to the cell to the right. (i.e go from grid[i][j] …
3414. Maximum Score of Non-overlapping Intervals
#Problem You are given a 2D integer array intervals, where intervals[i] = [lᵢ, rᵢ, weightᵢ]. Interval i starts at position lᵢ and ends at rᵢ, and has a weight of weightᵢ. You can choose up to 4 non-overlapping intervals. The score of the …
3298. Count Substrings That Can Be Rearranged to Contain a String II
#Problem 跟 3297. Count Substrings That Can Be Rearranged to Contain a String I 一模一样,只是多了一个注意点: Note that the memory limits in this problem are smaller than usual, so you must implement a solution with a linear runtime complexity. …
3410. Maximize Subarray Sum After Removing All Occurrences of One Element
#Problem You are given an integer array nums. You can do the following operation on the array at most once: Choose any integer x such that nums remains non-empty on removing all occurrences of x. Remove all occurrences of x from the array. …
3045. Count Prefix and Suffix Pairs II
#Problem 跟 3042. Count Prefix and Suffix Pairs I 一模一样,但单词数量从 50 提升到 10⁵,同时单词的长度也从 10 提升到 10⁵。 https://leetcode.com/problems/count-prefix-and-suffix-pairs-ii/ Constraints: 1 <= words.length <= 10⁵ 1 <= words[i].length <= 10⁵ words[i] …
3395. Subsequences with a Unique Middle Mode I
#Problem 唯一中间众数子序列。 Given an integer array nums, find the number of subsequences of size 5 of nums with a unique middle mode. A subsequence is an array that can be derived from another array by deleting some or no elements without changing …
3399. Smallest Substring With Identical Characters II
跟 3398. Smallest Substring With Identical Characters I 一模一样,只不过 s 的长度上限从 1000 增加到 10⁵。 https://leetcode.com/problems/smallest-substring-with-identical-characters-ii/ 直接用上次的代码没问题(最大堆或二分法均可)。
3398. Smallest Substring With Identical Characters I
#Problem You are given a binary string s of length n and an integer numOps. You are allowed to perform the following operation on s at most numOps times: Select any index i (where 0 <= i < n) and flip s[i]. If s[i] == '1', change s[i] to …
3405. Count the Number of Arrays with K Matching Adjacent Elements
#Problem You are given three integers n, m, k. A good array arr of size n is defined as follows: Each element in arr is in the inclusive range [1, m]. Exactly k indices i (where 1 <= i < n) satisfy the condition arr[i - 1] == arr[i]. Return …
732. My Calendar III
#Problem A k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.) You are given some events [startTime, endTime), after each given event, return an integer k representing …