dsa1 min read
Container with Most Water [Medium] — Greedy Two Pointers
Maximize water trapped between two vertical lines using inward two pointers that always move the shorter line inward.
Read →
webcoderspeed.com
1276 articles
Maximize water trapped between two vertical lines using inward two pointers that always move the shorter line inward.
Find minimum boats to save everyone where each boat carries at most 2 people with total weight <= limit, using sort + greedy two pointers.
Find all unique triplets summing to zero by sorting and using two pointers for each fixed element with careful duplicate skipping.
Find two numbers summing to target in a 1-indexed sorted array using inward two pointers in O(n) time O(1) space.
Count contiguous subarrays with product < k using a sliding window that divides from the left when product exceeds the limit.