3 ms·
The official leetcode endorsed proof is quite simple: https://leetcode.com/problems/container-with-most-water/discuss/6089/Anyone-who-has-a-O(N)-algorithm/7268
by lonelappde 7y ago
The official leetcode endorsed proof is quite simple: https://leetcode.com/problems/container-with-most-water/discuss/6089/Anyone-who-has-a-O(N)-algorithm/7268 https://leetcode.com/problems/container-with-most-water/disc...
It just doesn't bother with the counting argument that OP makes.
Also, the largest cross section of a cube is a rectangle of size √2, not a hexagon (3/4 √3). The largest regular polygon cross section is a hexagon.
http://mathworld.wolfram.com/Cube.html http://mathworld.wolfram.com/Cube.html