lhl
首页
python
leetcode
产品思想
软件测试
博客 (opens new window)
github (opens new window)
首页
python
leetcode
产品思想
软件测试
博客 (opens new window)
github (opens new window)
  • python

  • leetcode

    • 数组

      • 双指针

        • 15. 三数之和
        • 19. 删除链表的倒数第 N 个结点
      • 1.两数相加
      • 11. 盛最多水的容器
      • 26.删除有序数组中的重复项
      • 75. 颜色分类
      • 136.只出现一次的数字
      • 283.移动零
      • 448. 找到所有数组中消失的数字
      • 617. 合并二叉树
    • 位运算

    • 动态规划

    • 链表

    • 栈

    • 树

  • 软件测试

  • Git

  • linux

  • 产品

  • MySql

  • docker

  • leetcode
  • array
2023-04-29

盛最多水的容器

https://leetcode.cn/problems/container-with-most-water/submissions/ (opens new window) 需要注意的点

  1. 双指针
class Solution:
    def maxArea(self, height: List[int]) -> int:
        
        left = 0
        right = len(height)-1
        ret = 0

        while left < right:
            # 计算面积
            tmp = min(height[left], height[right])*(right-left)
            ret = max(ret, tmp)
            if height[left] > height[right]:
                right -= 1
            else:
                left += 1
            
            
        return ret

难度:中

1.两数相加
26.删除有序数组中的重复项

← 1.两数相加 26.删除有序数组中的重复项→

最近更新
01
lhl learn notes
02
filter
06-09
03
decorator
06-09
更多文章>
Theme by Vdoing
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式