
算法
Java
Leetcode
Golang
Java
Leetcode
Golang
Question
Given n non-negative integers
a1, a2, ..., an, where each represents a point at coordinate(i, ai). n vertical lines are drawn such that the two endpoints of line i is at(i, ai)and(i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
See it on Leetcode
|
|
Note
- You may not slant the container.
- Brute Force approach may cause TLE.
Solution in Brute Force - TLE
- java
1 |
public class { |
Solution in Java, C++ and Golang
- java
- cpp
- go
1 |
public class { |





近期评论