当前位置:网站首页>Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]
Leetcode: 11. Récipient contenant le plus d'eau [double pointeur + cupidité + enlèvement de la plaque la plus courte]
2022-07-03 18:39:00 【Rétrospective du roi dragon blanc】

Analyse
Au début, les deux pointeurs pointent vers une extrémité
Et regarde ce petit,Déplacez - le au milieu(Le but est d'enlever la plaque la plus courte,Il est possible de devenir plus grand)
ac code
class Solution:
def maxArea(self, height: List[int]) -> int:
# double pointers
n = len(height)
l, r = 0, n - 1
ans = 0
while l < r:
ans = max(ans, min(height[l], height[r]) * (r - l))
# Avidité:Retirer la plaque la plus courte
if height[l] < height[r]:
l += 1
else:
r -= 1
return ans
Résumé
Double pointeur avide enlever la plaque la plus courte
边栏推荐
- 硬盘监控和分析工具:Smartctl
- 2022-2028 global sepsis treatment drug industry research and trend analysis report
- Administrative division code acquisition
- Class exercises
- Su embedded training - Day10
- 199. Right view of binary tree - breadth search
- Sensor debugging process
- CV in transformer learning notes (continuously updated)
- Suffix derivation based on query object fields
- Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
猜你喜欢

CTO and programmer were both sentenced for losing control of the crawler
![[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*](/img/e8/67961bf8a589869bde2a0aa3e09605.jpg)
[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*

FBI warning: some people use AI to disguise themselves as others for remote interview

How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)

Unity webgl optimization

Shell script return value with which output

论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding

Bidding procurement scheme management of Oracle project management system

2022-2028 global marking ink industry research and trend analysis report

Okaleido, a multimedia NFT aggregation platform, is about to go online, and a new NFT era may come
随机推荐
Summary and Reflection on the third week of winter vacation
Unity2018 to wechat games without pictures
Introduction to SSH Remote execution command
Should I be laid off at the age of 40? IBM is suspected of age discrimination, calling its old employees "dinosaurs" and planning to dismiss, but the employees can't refute it
Use of unsafe class
[combinatorics] generating function (positive integer splitting | basic model of positive integer splitting | disordered splitting with restrictions)
Typescript configuration
Okaleido, a multimedia NFT aggregation platform, is about to go online, and a new NFT era may come
平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
SSH 远程执行命令简介
2022-2028 global lithium battery copper foil industry research and trend analysis report
English語法_名詞 - 分類
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
How many convolution methods does deep learning have? (including drawings)
Getting started with JDBC
CV in transformer learning notes (continuously updated)
2022-2028 global scar care product industry research and trend analysis report
Bidding procurement scheme management of Oracle project management system
组策略中开机脚本与登录脚本所使用的用户身份