I have a
vector<int>Index = [1,3,4,5,8,9]
vector<int>numbers = [1,2,3,4,5,6,7,8,9,10]
I want to use the indices in the vector index
to remove the numbers in vector<int>numbers
for(int t1 = 0; t1 < index.size(); t1++)
But my program keeps on crashing.
I tried the reverse way also :
for(int t1 = index.size()-1; t1 > 0; --t1)
I also tried to decrement the values in the vector Index since every time i remove an element from vector numbers the index will decrease right?
So also it crashed
int counter = 0;
for(int t1 = index.size()-1; t1 > 0; t1--)
// cout << index[t1]<<endl;
words.erase(words.begin() +( index[t1]-counter));
counter = counter + 1;