+ 1
How to erase duplicates in vector?
I am quite new to using vectors and would like to manually create functions to better understand before using libraries. I am trying to remove duplicates in my vector but I do not know what to I include here to solve it manually?
1 Answer
+ 4
Due to how vector work which I don't have enough time to be explaining right now, the best method to create a unique vector item is actually to
create a "set" from a vector, then reassign the values of the set to the vector
However, I've managed to provide two alternative ways that are performance considerate irrespective of how large the vector items could be.
There are some things where you don't have any choice than to use the inbuilt functions, it's not a shame using them although i understand why most beginners want to avoid them. therefore, I'd like to inform you that YOU CAN NEVER WRITE a better function than the one already provided by the language. So it's good to always use them
https://code.sololearn.com/cimB35cx2G9z/?ref=app