title: What is time complexity for the following code?
body: <p>It seems the complexity of the following code should be O(n^2) but it's O(n), how?</p>
  
  <pre><code>void fun(int n, int arr[])
  {
      int i = 0, j = 0;
      for(; i &lt; n; ++i)
          while(j &lt; n &amp;&amp; arr[i] &lt; arr[j])
              j++;
  }
  </code></pre>