LeetCode11. 盛最多水的容器 Python3

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Victordas/article/details/82755905

在这里插入图片描述

首先贴上我用python写的日常简单超时小程序:

class Solution:
    def maxArea(self, num_list):
        """
        :type height: List[int]
        :rtype: int
        """
        a = len(num_list) - 1
        i = a
        temp = 0
        while i > 0:
            for j in range(0, len(num_list)-1):
                if j < i + j < len(num_list):
                    if num_list[j] <= num_list[i+j]:
                        if num_list[j]*i > temp:
                            temp = num_list[j]*i
                    elif num_list[j] > num_list[i+j]:
                        if num_list[j+i]*i > temp:
                            temp = num_list[j+i]*i
            i -= 1
        return temp

https://blog.csdn.net/weixin_41958153/article/details/80554007
参考了这个思路之后发现自己确实想的太耿直了。。
好吧确实很简单。。应该再想想的

猜你喜欢

转载自blog.csdn.net/Victordas/article/details/82755905