classSolution { public: //Function to find a continuous sub-array which adds up to a given number. vector<int> subarraySum(int arr[], int n, longlong s) { int l = 0, r = 0; longlong sum = 0; while(r < n) { if(sum > s) { sum -= arr[l++]; } elseif(sum < s) { sum += arr[r++]; } if(sum == s) return {l + 1, r}; } while(sum != s and l < n) { sum -= arr[l++]; } if(sum == s) return {l + 1, r}; return {-1}; } };