It seem a little awkward to ask this question, but i'm still struggling to find the answer by myself.
I have an array of elements, several of them are duplicated. For example:
list = [ '1' , '2' , '3' , '1' , '4' , '5' , '3' ]
As can be seen, "1" and "3" exist twice. Now I want to customize it, make it "clean". This is what I always do:
//Create a new list
listCustomize = []
for element in list:
//Check if element already in listCustomize or not, if yes, dont add it
if element not in listCustomize:
listCustomize.append(element)
By this way, I can have a new array that customized
listCustomize = [ '1' ,'2' , '3' , '4' , '5' ]
SO HERE THE PROBLEM, my original array includes hundreds of thousands of elements. Therefore the program is extremely slow.
May someone suggest any more sophisticate approach for this issue? I am thinking about using multi-threading, or use a database to store the original array....
Note: What kind of programming language is not a problem . But prefer Perl/Python/Java/C++
Thank you and best regards.
Alex