exelover's blog

By exelover, history, 10 months ago, In English,

10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The problem is that you erase element from the vector O(n) times. and since the size of the vector is O(n), your time complexity would become O(N^2), which is too slow. You should use queue instead as you are only removing the top element.