Skip to content

Instantly share code, notes, and snippets.

@decagondev
Created April 23, 2025 21:13
Show Gist options
  • Save decagondev/edc31a98ec54fe0e7829d6894ddbdd25 to your computer and use it in GitHub Desktop.
Save decagondev/edc31a98ec54fe0e7829d6894ddbdd25 to your computer and use it in GitHub Desktop.

PROBLEM 5: Container With Most Water

Problem Statement

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai), n vertical lines are drawn. Find two lines that together with the x-axis forms a container, such that the container contains the most water.

Concepts Covered

  • Two Pointer Technique
  • Optimization

Examples

Input: height = [1,8,6,2,5,4,8,3,7]
Output: 49

Input: height = [1,1]
Output: 1

Starter Code

def max_area(height: list[int]) -> int:
    # Implement your solution here
    pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment