C ++ easy to step on pit
Added at any time
- While circulating STL not erase ()
//自己写的求交集RE了
for (set <int> ::iterator it = s.begin(); it != s.end(); it++)
if (*it == x)
s.erase(it); //RE
The solution: use vector element to be deleted record, open a new cycle of the vector, the operation can be set.
- Redefined operator when using unique () / lower_bound () <should meet strict smaller than (equal to if return false).
- priority_queue large root stack, sort in ascending.
Welcome to add