当前位置:网站首页>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
边栏推荐
- 041. (2.10) talk about manpower outsourcing
- Self executing function
- [Yu Yue education] world reference materials of Microbiology in Shanghai Jiaotong University
- What London Silver Trading software supports multiple languages
- Torch learning notes (6) -- logistic regression model (self training)
- 2022-2028 global sepsis treatment drug industry research and trend analysis report
- Su embedded training - Day10
- 硬盘监控和分析工具:Smartctl
- Count the number of pixel values in the image
- Image 24 bit depth to 8 bit depth
猜你喜欢

Computer graduation project PHP library book borrowing management system

An academic paper sharing and approval system based on PHP for computer graduation design
![The number of incremental paths in the grid graph [dfs reverse path + memory dfs]](/img/57/ff494db248171253996dd6c9110715.png)
The number of incremental paths in the grid graph [dfs reverse path + memory dfs]

Valentine's day, send you a little red flower~

Caddy server agent

Computer graduation design PHP makeup sales Beauty shopping mall
![[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)](/img/e6/9880e708aed42dc82c94aea002020c.jpg)
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)

Administrative division code acquisition
![[untitled]](/img/83/5a57ed90aaafde94db600246256867.jpg)
[untitled]

Summary and Reflection on the third week of winter vacation
随机推荐
How to track the real-time trend of Bank of London
Class exercises
2022-2028 global scar care product industry research and trend analysis report
Zero length array
2022-2028 global marking ink industry research and trend analysis report
平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
[combinatorics] generating function (positive integer splitting | unordered | ordered | allowed repetition | not allowed repetition | unordered not repeated splitting | unordered repeated splitting)
Shell script return value with which output
企业级自定义表单引擎解决方案(十二)--表单规则引擎2
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
An academic paper sharing and approval system based on PHP for computer graduation design
[combinatorics] generating function (positive integer splitting | unordered non repeated splitting example)
Bidding procurement scheme management of Oracle project management system
MySQL duplicate check
Sensor debugging process
Niuke monthly race 31 minus integer
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)
There are several levels of personal income tax