力扣第 162 场双周赛

本文最后更新于 2 分钟前,文中所描述的信息可能已发生改变。

3633. 最早完成陆地和水上游乐设施的时间 I - 力扣(LeetCode)

解题思路

具体见 Q3

示例代码

python
class Solution:
    def earliestFinishTime(self, landStartTime: List[int], landDuration: List[int], waterStartTime: List[int], waterDuration: List[int]) -> int:
        land = min(x + y for x, y in zip(landStartTime, landDuration))
        water = min(x + y for x, y in zip(waterStartTime, waterDuration))
        res1 = min(max(x, water) + y for x, y in zip(landStartTime, landDuration))
        res2 = min(max(x, land) + y for x, y in zip(waterStartTime, waterDuration))
        return min(res1, res2)

3634. 使数组平衡的最少移除数目 - 力扣(LeetCode)

解题思路

排序 + 二分或滑窗

示例代码

python
class Solution:
    def minRemoval(self, nums: List[int], k: int) -> int:
        n = len(nums)
        ans = n
        nums.sort()
        for i, x in enumerate(nums):
            r = bisect_right(nums, x * k)
            if i + n - r < ans:
                ans = i + n - r
        return ans

3635. 最早完成陆地和水上游乐设施的时间 II - 力扣(LeetCode)

解题思路

贪心,分别计算最早结束时间,再交替计算原始开始时间和另一项游戏的最早结束时间即可

示例代码

python
class Solution:
    def earliestFinishTime(self, landStartTime: List[int], landDuration: List[int], waterStartTime: List[int], waterDuration: List[int]) -> int:
        land = min(x + y for x, y in zip(landStartTime, landDuration))
        water = min(x + y for x, y in zip(waterStartTime, waterDuration))
        res1 = min(max(x, water) + y for x, y in zip(landStartTime, landDuration))
        res2 = min(max(x, land) + y for x, y in zip(waterStartTime, waterDuration))
        return min(res1, res2)

3636. 查询超过阈值频率最高元素 - 力扣(LeetCode)

解题思路

参考:这道题很神秘,以后再来解决吧!

示例代码

python
TODO
力扣第 462 场周赛
力扣第 460 场周赛