title: Longest Sub Array
body: <p>Can anyone suggest a simple solution for the below question.</p>
  
  <blockquote>
    <p><strong>Longest Sub-array</strong>: Find the length of longest contiguous sub-array where the sum of the elements in subarray is less than or equal to "k".</p>
  </blockquote>
  
  <p>Inputs are: <code>array</code> and <code>k</code>.</p>
  
  <p>Example:</p>
  
  <pre><code>Array = {1,2,3}, k = 3
  </code></pre>
  
  <p>Output: </p>
  
  <blockquote>
    <p>2</p>
  </blockquote>
  
  <p>Explanation:</p>
  
  <blockquote>
    <p>Sub arrays : {1},{2},{3},{1,2},{2,3},{1,2,3}</p>
    
    <p>{1,2} => max length = 2;  1+2 = 3 (&lt;=k);</p>
  </blockquote>