title: Find Subarray With Given Sum 1
signature: function findSubarrayWithGivenSum1($arr, $n, $sum) {
source_py: def find_subarray_with_given_sum_1(arr, n, sum):
      curr_sum = arr[0]
      start = 0
      i = 1
      while (i <= n):
          while ((curr_sum > sum) and (start < (i - 1))):
              curr_sum = (curr_sum - arr[start])
              start += 1
          if (curr_sum == sum):
              print('Sum found between indexes')
              print(('%d and %d' % (start, (i - 1))))
              return 1
          if (i < n):
              curr_sum = (curr_sum + arr[i])
          i += 1
      print('No subarray found')
      return 0
source_cpp: int find_subarray_with_given_sum_1(vector<int> arr, int n, int sum) {
    int curr_sum = arr [ 0 ], start = 0, i;
    for ( i = 1;
    i <= n;
    i ++ ) {
      while ( curr_sum > sum && start < i - 1 ) {
        curr_sum = curr_sum - arr [ start ];
        start ++;
      }
      if ( curr_sum == sum ) {
        return 1;
      }
      if ( i < n ) curr_sum = curr_sum + arr [ i ];
    }
    return 0;
  }