title: Find All Numbers Disappeared in an Array (Getting IndexOutOFBoundsException
body: <p>I keep getting a IndexOutOFBoundsException and i cant seem to find where. Ive spent ages trying to figure this out. Any help would be appreciated. Thanks</p>
  
  <pre><code>class Solution {
  
  public List&lt;Integer&gt; findDisappearedNumbers(int[] nums) {
  
      if(nums.length &lt; 2){
          return new ArrayList&lt;Integer&gt;();
      }
  
      List&lt;Integer&gt; ret = new ArrayList&lt;Integer&gt;(nums.length);
  
      for(int i=0; i &lt; nums.length; i++){
          ret.set(i,i);
      }
  
      for(int i=0; i &lt; nums.length; i++){            
          ret.set(nums[i]-1, nums[i]);
      }     
  
      for(int i=0; i &lt; nums.length; i++){ 
          if(ret.get(i) == 0){
              ret.set(i, i+1);
          }
          else{
              ret.remove(i);
          }
      }
      return ret;       
  }
  </code></pre>
  
  <p>}</p>