title: How to efficiently check if a list of consecutive numbers is missing any elements
body: <p>I have this array</p>
  
  <pre><code>var arr = ["s00","s01","s02","s03","s04","s05","s07","s08","s09","s10","s11","s12","s13","s14","s17","s19","s20","s21","s22","s24","s25","s26","s27","s28","s30","s32","s33","s34","s36","s38","s39","s41","s43","s44","s45","s46","s47","s48","s49","s50","s51","s52","s53","s54","s55","s56","s58","s60","s61","s62","s63","s64","s65","s67","s69","s70"];
  </code></pre>
  
  <p>I was trying to find an algorithm that will tell me which <code>s</code>s are missing. As you can see, the list consists of consecutive <code>s</code>s (<code>s1</code>, <code>s2</code>, etc.).</p>
  
  <p>At first I went with this solution:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    var arr = ["s00","s01","s02","s03","s04","s05","s07","s08","s09","s10","s11","s12","s13","s14","s17","s19","s20","s21","s22","s24","s25","s26","s27","s28","s30","s32","s33","s34","s36","s38","s39","s41","s43","s44","s45","s46","s47","s48","s49","s50","s51","s52","s53","s54","s55","s56","s58","s60","s61","s62","s63","s64","s65","s67","s69","s70"];
  for (var i=1;i&lt;arr.length;i++){
      var thisI = parseInt(arr[i].toLowerCase().split("s")[1]);
      var prevI = parseInt(arr[i-1].toLowerCase().split("s")[1]);
      if (thisI != prevI+1)
        console.log(`Seems like ${prevI+1} is missing. thisI is ${thisI} and prevI is ${prevI}`)
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>But this method fails for more than one consecutive numbers missing (<code>s15</code>, <code>s16</code>). So I added a <code>while</code> loop which works.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var arr = ["s00","s01","s02","s03","s04","s05","s07","s08","s09","s10","s11","s12","s13","s14","s17","s19","s20","s21","s22","s24","s25","s26","s27","s28","s30","s32","s33","s34","s36","s38","s39","s41","s43","s44","s45","s46","s47","s48","s49","s50","s51","s52","s53","s54","s55","s56","s58","s60","s61","s62","s63","s64","s65","s67","s69","s70"];
  for (var i=1;i&lt;arr.length;i++){
    var thisI = parseInt(arr[i].toLowerCase().split("s")[1]);
    var prevI = parseInt(arr[i-1].toLowerCase().split("s")[1]);
    if (thisI != prevI+1) {
      while(thisI-1 !== prevI++){
         console.log(`Seems like ${prevI} is missing. thisI is ${thisI} and prevI is ${prevI}`)
      }
     }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>However, I feel like I'm overly complicating things.
  I thought of creating an ideal array:</p>
  
  <pre><code>var idealArray = [];
  for (var i =0; i&lt;200;i++) {
    idealArray.push(i)
  }
  </code></pre>
  
  <p>And then, while checking, tamper with my array (<code>arr</code>) so that the loop checks two arrays of the same length. I.e., use this solution:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var idealArray = [];
  for (var i =0; i&lt;200;i++) {
    idealArray.push(i)
  }
  var arr = ["s00","s01","s02","s03","s04","s05","s07","s08","s09","s10","s11","s12","s13","s14","s17","s19","s20","s21","s22","s24","s25","s26","s27","s28","s30","s32","s33","s34","s36","s38","s39","s41","s43","s44","s45","s46","s47","s48","s49","s50","s51","s52","s53","s54","s55","s56","s58","s60","s61","s62","s63","s64","s65","s67","s69","s70"];
  for (let i = 0; i&lt;idealArray.length;i++){
    if (parseInt(arr[i].toLowerCase().split("s")[1]) != idealArray[i]) {
      console.log(`Seems like ${idealArray[i]}is missing`);
      arr.splice(i,0,"dummyel")
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>But, once again, I have the feeling that creating this second array is not very efficient either (thinking of a big list, I'd waste unnecessary space).</p>
  
  <p>So... how do I efficiently perform this task in JavaScript? (Efficiently meaning as close to O(1) as possible both for time complexity and for space complexity.)</p>