Container With Most Water LeetCode Solution

🚀 Day 5/100 – LeetCode Journey Today’s problem: Container With Most Water 💧 Approach (Two Pointer) 1. Take two pointers: left = 0 right = n - 1 2. Workflow: Calculate height → min(height[left], height[right]) Width → right - left Area → height × width Update maxWater if needed ✅ 3. Move pointer: Move the smaller height pointer Because larger height won’t increase area if width decreases. 🧠 Key Idea: Area depends on minimum height, so always try to improve the smaller one. ⚡ Time Complexity: O(n) → single traversal 🧠 Space Complexity: O(1) → no extra space Thanks to RAVI KUMAR Sir for guidance! Consistency building day by day 💪 #100DaysOfCode #LeetCode #DSA #Java

  • text

To view or add a comment, sign in

Explore content categories