Vector in c++ (auto it)

Please format your code - the forum software has mangled it and it won’t compile! :slight_smile:

Edit:

while(query--)
{
cin>>x;
auto it = find(v.begin(),v.end(),x);

This loop is executed O(Q) times and std::find is linear-time, so each call takes O(N), so this is an O(N \times Q) algorithm - too slow to run in ~2 secs with N=10^5 and Q=10^5.

2 Likes