In this video we will see how to find a continuous subarray which adds to a given sum, from an unsorted array of non-negative integers. There may be more than one subarrays with sum as the given sum, print first such subarray.
Example:
Input:
arr = [1, 4, 20, 3, 10, 5]
sum = 33
Output: Sum found between indexes 2 and 4
Explanation: Sum of elements between indices 2 and 4 is 20 + 3 + 10 = 33
Check out the video to see how we implement this!!
Practice Problem: https://practice.geeksforgeeks.org/problems/subarray-with-given-sum-1587115621/1
Article: https://www.geeksforgeeks.org/find-subarray-with-given-sum/
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/