title: How to write the code with less time complexity for finding the missing element in given array range?
body: <p>My function should return the missing element in a given array range.
  So i first sorted the array and checked if the difference between i and i+1 is not equal to 1, i'm returning the missing element.</p>
  
  <pre><code>// Given an array A such that:
  // A[0] = 2
  // A[1] = 3
  // A[2] = 1
  // A[3] = 5
  // the function should return 4, as it is the missing element.
  
  function solution(A) {
    A.sort((a,b) =&gt; {
      return b&lt;a;
    })
    var len = A.length;
    var missing;
    for( var i = 0; i&lt; len; i++){
      if( A[i+1] - A[i] &gt;1){
        missing = A[i]+1;
      }
    }
    return missing;
  }
  </code></pre>
  
  <p>I did like above, but how to write it more efficiently??</p>