I don't know the answer to your first question, but there have been a number of posts asking how to remove duplicates so if you do a search you may find the answer. But if you can use a collection instead of an array, then you can check for a duplicate key with only 2 or 3 lines of code and I'm sure that the collection approach is faster than any approach using an array (unless there is some API that you can use).