Container With Most Water - LeetCode 11 | Two Pointers Explained | Day 12 of My LeetCode Journey
Автор: Ashwini Kemshetty
Загружено: 2026-01-18
Просмотров: 12
Описание:
🎯 Day 12 of My LeetCode Journey | Container With Most Water (LeetCode 11)
In this video, I solve LeetCode Problem #11 - Container With Most Water. This is a classic Two Pointers problem where we find the maximum area formed between two vertical lines in O(n) time.
🔗 Problem Link: https://leetcode.com/problems/contain...
📌 PROBLEM SUMMARY:
You are given an integer array height where each element represents a vertical line at index i.
Find two lines that form a container with the x-axis such that it holds the MOST water.
Return the maximum amount of water. (You cannot slant the container.)
Example 1:
Input: height = [1,8,6,2,5,4,8,3,7]
Output: 49
Example 2:
Input: height = [1,1]
Output: 1
💡 KEY INSIGHT (Two Pointers):
Start with pointers at both ends.
Area = (right - left) * min(height[left], height[right])
Move the pointer with the smaller height inward to potentially find a better container.
📊 COMPLEXITY:
• Time: O(n)
• Space: O(1)
🎓 DIFFICULTY: Medium
🏷️ TOPICS: Array, Two Pointers
🔔 SUBSCRIBE for daily LeetCode solutions and coding challenges!
👍 LIKE if you found this helpful!
💬 COMMENT your approach or questions below!
📚 MY LEETCODE JOURNEY PLAYLIST:
• Leetcode
🤝 CONNECT WITH ME:
• GitHub: https://github.com/ashwinikemshetty
• LinkedIn: / ashwinikemshetty
---
#LeetCode #ContainerWithMostWater #LeetCode11 #Day12 #TwoPointers #CodingInterview #DSA #Algorithms #ProblemSolving #100DaysOfCode
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: