Container With Most Water
📖 Scenario: You are helping a water storage company find the best two vertical lines to hold the most water between them. Each line's height is given, and you want to find the maximum water container that can be formed between any two lines.
🎯 Goal: Build a program that finds the maximum amount of water that can be contained between two lines represented by an array of heights.
📋 What You'll Learn
Create an array called
height with the exact values: 1, 8, 6, 2, 5, 4, 8, 3, 7Create two integer variables
left and right to point to the start and end of the arrayUse a
while loop to move the pointers and calculate the maximum water containerPrint the maximum water container value using
printf💡 Why This Matters
🌍 Real World
This problem models how to find the best container shape to hold the most water between vertical lines, useful in storage and design.
💼 Career
Understanding two-pointer techniques and array traversal is important for coding interviews and real-world algorithm optimization.
Progress0 / 4 steps
