filmov
tv
Subarray with given sum || GeeksForGeeks || Sliding Window || Begineers DSA Sheet

Показать описание
Problem Statement:
Given an unsorted array A of size N that contains only non negative integers, find a continuous sub-array that adds to a given number S and return the left and right index(1-based indexing) of that subarray.
In case of multiple subarrays, return the subarray indexes which come first on moving from left to right.
Note:- You have to return an ArrayList consisting of two elements left and right. In case no such subarray exists return an array consisting of element -1.
Problem Link:
Tags:
Algorithms
Arrays
Data Structures
prefix-sum
Searching
sliding-window
Given an unsorted array A of size N that contains only non negative integers, find a continuous sub-array that adds to a given number S and return the left and right index(1-based indexing) of that subarray.
In case of multiple subarrays, return the subarray indexes which come first on moving from left to right.
Note:- You have to return an ArrayList consisting of two elements left and right. In case no such subarray exists return an array consisting of element -1.
Problem Link:
Tags:
Algorithms
Arrays
Data Structures
prefix-sum
Searching
sliding-window