Minimumsizze Sub Array
Input: target = 7, nums = [2,3,1,2,4,3], output=2
Start with left = 0, sum = 0, and minLen = Infinity.
Move the right pointer through the array, adding each nums[right] to sum.
Whenever the sum becomes greater than or equal to the target,
update minLen as the smaller of its current value and the current window length (right - left + 1).
Then, shrink the window from the left by subtracting nums[left] from sum and moving left forward,
repeating this until sum drops below target.
Continue expanding and shrinking the window this way until the end of the array.
After finishing, if minLen was never updated, return 0; otherwise, return minLen.
Is Subsequence
Input: s = “abc”, t = “ahbgdc” Output: true
Keep both index from string at 0
Iterate through target string
– if match char , increment both index
– else t index
– if s index at end subsequence found
Container With Most Water
Initialize two pointers
– Start from both ends of the array.
Initialize maxArea = 0
– Keeps track of the largest water container found so far.
Loop while left < right
– The container is formed by lines at left and right.
Compute area of current container
– area = (right – left) * Math.min(height[left], height[right])
– Width = distance between two pointers → (right – left)
– Height = shorter line → Math.min(height[left], height[right])
– Because water can’t go higher than the shorter side.
Update maximum area
– maxArea = Math.max(maxArea, area)
Move the pointer pointing to the smaller height
The smaller height limits the container’s height.
Moving it inward might find a taller line → potential larger area.
Moving the taller one doesn’t help since width also reduces.
Continue until pointers meet.
Return the maximum area found.
Three Sum
Sort the array → so duplicates are easier to handle.
Iterate over the array:
– Let current element = nums[i]
– Set two pointers:
– left = i + 1, right = n - 1
– While left < right:
– Compute sum = nums[i] + nums[left] + nums[right]
– If sum === 0: found a triplet → push it into result.
– Move left and right while skipping duplicates.
– If sum < 0: increase left
– If sum > 0: decrease right
Skip duplicate values for nums[i] too.


