leetcode628 python3 124ms 三个数字的最大乘积

# 不是最优解,最优解应该用topK的思路
class Solution:
    def maximumProduct(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        nums.sort()
        res = [nums[-3]*nums[-2]*nums[-1], nums[0]*nums[1]*nums[-1]]
        return max(res)
        
posted @ 2018-08-09 15:51  一条图图犬  阅读(397)  评论(0编辑  收藏  举报