当前位置:网站首页>【Hot100】11. Container with the most water
【Hot100】11. Container with the most water
2022-06-30 06:54:00 【Wang Liuliu's it daily】
11. Container for the most water
Medium question
Double pointer :
Refer to the explanation of the question :https://leetcode.cn/problems/container-with-most-water/solution/container-with-most-water-shuang-zhi-zhen-fa-yi-do/
class Solution {
public int maxArea(int[] height) {
int i = 0, j = height.length - 1, res = 0;
while(i < j) {
res = height[i] < height[j] ?
Math.max(res, (j - i) * height[i++]):
Math.max(res, (j - i) * height[j--]);
}
return res;
}
}
边栏推荐
- Pycharm shortcut key
- Imxq Freescale yocto project compilation record
- leetcode:98. 验证二叉搜索树
- RT thread migration to s5p4418 (IV): thread synchronization
- First experience of Galaxy Kirin
- RT thread Kernel Implementation (V): timer
- RT thread application
- 【转】存储器结构、cache、DMA架构分析
- C language: exercise 3
- 【每日一题】535. TinyURL 的加密与解密
猜你喜欢
MySQL Optimization: from more than ten seconds to 300 milliseconds
Fastapi learning Day2
File Transfer Protocol,FTP文件共享服务器
经纬恒润再次荣获PACCAR集团 10PPM 质量奖
Judge whether H5 is in wechat environment or enterprise wechat environment at both ends
First experience of Galaxy Kirin
RT thread migration to s5p4418 (III): static memory pool management
神经网络入门
[JSON tutorial] Chapter 1 learning notes
How does the CPU recognize the code?
随机推荐
High performance distributed execution framework ray
基础刷题(一)
SOC_ AHB_ SD_ IF
阿里云买的40G高效云盘挂载只有20G
GO安装以及配置(1)
Authority management system
1.4 - 定点数与浮点数
Bat 使用细节2
[transfer] analysis of memory structure, cache and DMA architecture
[JSON tutorial] Chapter 1 learning notes
ROS system problem: rosdep init
随机网络,无标度网络,小世界网络以及NS小世界的性能对比matlab仿真
Record one time of Tencent Test Development Engineer's automation interface test practice experience
成品升级程序
【模糊神经网络】基于模糊神经网络的移动机器人路径规划
第一行代码(第三版)学习笔记
Definition and use of ROS topic messages
RT thread migration to s5p4418 (I): scheduler
How to set the hot deployment of idea web project
Initial love with mqtt