Multiply every visited index's value with -1 and then traverse at end to get which all indexes' have positive values Push them in answer array and then return that array.

'''

class Solution {

public:

vector<int> findDisappearedNumbers(vector<int>& v) {

for(int i=0;i<v.size();i++){

if(v[abs(v[i])-1]>0)

v[abs(v[i])-1]*=-1;

}

vector<int> ans;

for(int i=0;i<v.size();i++){

if(v[i]>0)

ans.push_back(i+1);

}

return ans;

}

};

'''