摘要: 排序,返回中值。 class Solution: def majorityElement(self, nums: List[int]) -> int: #always exists nums.sort() return nums[len(nums)//2] 阅读全文
posted @ 2024-06-30 14:16 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 原来leetcode使用Count也不需要import collections class Solution: def removeDuplicates(self, nums: List[int]) -> int: # len =0 if len(nums) == 0: return 0 # els 阅读全文
posted @ 2024-06-30 12:58 夜歌乘年少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 开刷Top Interview 150 class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nu 阅读全文
posted @ 2024-06-30 11:08 夜歌乘年少 阅读(1) 评论(0) 推荐(0) 编辑