Quote:
Originally Posted by
yifangt
corona688, can I make sure the difference between list<> and vector <> can be hours?
Vector is not "fast" and list is not "slow".
If you try to insert in arbitrary places anywhere inside a vector, it will be slow.
If you try to use a list for random access, it will be slow.
What I have suggested is better suited for lists than vectors.
Quote:
I must have missed something big for my code.
You are comparing every element to every other element. If you have 300 elements, that's
90,000 comparisons. If you have 3000 elements, that's 9
million comparisons. Any sequence you remove early means 300 fewer loops later.
You are also searching for strings inside strings without using any sort of index, but that would be complicated.