title: Find sub-array with given sum sub array should be continuous
body: <p><strong>Find sub-array with given sum sub array should be continuous.</strong><br>
  This question is from GeeksForGeeks. <a href="http://www.geeksforgeeks.org/find-subarray-with-given-sum/" rel="nofollow">enter link description here</a>  </p>
  
  <pre><code>int subArraySum(int arr[], int n, int sum)
  {
      /* Initialize curr_sum as value of first element
         and starting point as 0 */
      int curr_sum = arr[0], start = 0, i;
  
      /* Add elements one by one to curr_sum and if the curr_sum exceeds the
         sum, then remove starting element */
      for (i = 1; i &lt;= n; i++)
      {
          // If curr_sum exceeds the sum, then remove the starting elements
          while (curr_sum &gt; sum &amp;&amp; start &lt; i-1) // Check This
          {
              curr_sum = curr_sum - arr[start];
              start++;
          }
  
          // If curr_sum becomes equal to sum, then return true
          if (curr_sum == sum)
          {
              printf ("Sum found between indexes %d and %d", start, i-1);
              return 1;
          }
  
          // Add this element to curr_sum
          if (i &lt; n)
            curr_sum = curr_sum + arr[i];
      }
  
      // If we reach here, then no subarray
      printf("No subarray found");
      return 0;
  }
  </code></pre>
  
  <p>In this we are using condition <strong>while (curr_sum > sum &amp;&amp; start &lt; i-1)</strong>. I don't think we need comparing start with i-1. We are able to do this <strong>only while (curr_sum > sum)</strong>. Please reply.</p>