Container With Most Water
Choose two vertical lines that hold the most water. Start with the widest pair and always move the shorter line inward, which turns an O(n²) search into one pass.
Spotted a mistake in this lesson?Report an issue →
Choose two vertical lines that hold the most water. Start with the widest pair and always move the shorter line inward, which turns an O(n²) search into one pass.