title: maximum sum of n consecutive elements of array
body: <p>How to find the maximum sum of <code>n</code> consecutive numbers of an array? For example if our array is <code>{2,5,3,4,6}</code> and <code>n == 2</code> then output should be <code>10</code> (i.e. <code>6 + 4</code>).</p>
  
  <p>I am able to get the logic right for small values of array size and small values of <code>n</code>. But when the array size and n are too large like around 10<sup>5</sup>, my code takes a lot of time. Please suggest an optimized approach.</p>
  
  <p>My code snipped:</p>
  
  <pre><code>for(int i = 0; i &lt;= n - h; i++) {
    int count = 0;
    for(int k = i; k &lt; i + h; k++) {
      count = count + arr[k];
    }
    if(i == 0) {
      ans[z] = count;
    } else if(i != 0) {
      if(count &lt; ans[z]) {
        ans[z] = count;
      }
    }
    count = 0;
  }
  </code></pre>