from typing import List class Solution: def maximunProduct(self, nums: List[int]) -> int: # 默认是升序 nums.sort() length = len(nums) if length == 3: return nums[0] * nums[1] * nums[2] else: return max(nums[0] * nums[1] * nums[-1], nums[-1] * nums[-2] * nums[-3])
if __name__ == '__main__': s = Solution() nums = [-1, 2, 4, -6, 3, 5] res = s.maximunProduct(nums) print(res)
60