返回数组中最大的三个数
class Solution: def maxThreeNum(self, nums: List[int]): n1, n2, n3 = 0 for i in range(len(nums)): if nums[i] > n1: n2 = n1 n1 = nums[i] elif nums[i] > n2: n3 = n2 n2 = nums[i] elif nums[i] > n3: n3 = nums[i] return n1, n2, n3
class Solution: def maxThreeNum(self, nums: List[int]): n1, n2, n3 = 0 for i in range(len(nums)): if nums[i] > n1: n2 = n1 n1 = nums[i] elif nums[i] > n2: n3 = n2 n2 = nums[i] elif nums[i] > n3: n3 = nums[i] return n1, n2, n3