Two Pointer Method

Minimum Size Subarray Sum

Problem Statement Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead. Sample Test Cases Problem Solution The better approach to solving the problem is to use two pointers, ptr1 and ptr2, where ptr1 represents the starting index …

Minimum Size Subarray Sum Read More »


Problems statement Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Sample Test Cases Problem Solution We Solve this question by fixing the first element and then finding the other two using two pointer algorithm. So first we sort the array in ascending …

3 SUM Read More »

Scroll to Top
[gravityforms id="5" description="false" titla="false" ajax="true"]