<p>Given an array <code>nums</code> of <code>n</code> integers where <code>nums[i]</code> is in the range <code>[1, n]</code>, return <em>an array of all the integers in the range</em> <code>[1, n]</code> <em>that do not appear in</em> <code>nums</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> nums = [4,3,2,7,8,2,3,1]
<strong>Output:</strong> [5,6]
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> nums = [1,1]
<strong>Output:</strong> [2]
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == nums.length</code></li>
	<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= nums[i] &lt;= n</code></li>
</ul>

<p>&nbsp;</p>
<p><strong>Follow up:</strong> Could you do it without extra space and in <code>O(n)</code> runtime? You may assume the returned list does not count as extra space.</p>

class Solution {
public:
    vector<int> findDisappearedNumbers(vector<int>& nums) {

         vector<int> solution;
         vector<int> temp;
    
        //sort
        make_heap(nums.begin(),nums.end());
        sort_heap(nums.begin(),nums.end());
        int nums_max = nums.back();
        int nums_size = nums.size();
        int nums_min = nums.front();
        if ((nums_min!=1)){
            temp.resize(abs(nums_min-1));
            iota(temp.begin(),temp.end(), (1));
            solution.insert(solution.end(),temp.begin(), temp.end());
        }
        temp.clear();
        for (size_t i = 0; i<(nums.size()-1); ++i){

            if ((nums[i+1]-nums[i])>1){
                temp.resize((nums[i+1]-nums[i])-1);
                iota(temp.begin(),temp.end(), (nums[i]+1));
                solution.insert(solution.end(),temp.begin(), temp.end());

            }
            temp.clear();

        }
       
        if ((nums_max!=nums_size)){
            temp.resize(abs(nums_max-nums_size));
            iota(temp.begin(),temp.end(), (nums_max + 1));
            solution.insert(solution.end(),temp.begin(), temp.end());
        }
        
        return solution;
        
    }
};
37891