LeetCode Biweekly Contest 162

3633. 最早完成陆地和水上游乐设施的时间 I ​

题目类型 ​

#贪心

解题思路 ​

参考:思路同 3635

示例代码 ​

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. 使数组平衡的最少移除数目 ​

题目类型 ​

#排序 #二分 #滑动窗口

解题思路 ​

排序 + 二分或滑窗

示例代码 ​

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 ​

题目类型 ​

#贪心

解题思路 ​

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

示例代码 ​

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. 查询超过阈值频率最高元素 ​

题目类型 ​

#未解决

解题思路 ​

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

示例代码 ​

python
TODO
LeetCode Weekly Contest 462
LeetCode Weekly Contest 460
由 Valaxy v1.2.0 驱动|主题-Yunv1.2.0
本站总浏览量: -本站总访客数: -
本站已运行0 天0 小时0 分0 秒