• Non Unique Elements - Dariansweb

Question related to mission Non-unique Elements

 

First off, I don't want the answers. I truly want to figure these things out.

I want to know if my thinking is correct. I don't want start looking at other posts right now because I'm not interested in accidentally getting an answer. If I approach the way "I think" and then change the way "I think" then I will be successful.

I want to ask the forum if my thinking will be the way a computer should think about finding the answer. I know it sounds selfish, but really I'm hoping it helps bring a different approach to understanding the best answer for a computer to process.

// Create myVariable to store each element of the array
// Search array for the value of myVariable other than itself
// Store in myResults value if it has a match other than itself
// Do not store in myResults if it has no match
// Remove all elements of the array that are searched
// Update myVariable to the next element of the array

Now, I was thinking after the results are stored in myResults the computer should search if the new myVariable is already in myResults before searching the original array.

Or, is there a way to remove elements of the array if they are matched with other elements. By doing so, the original array becomes smaller and the computer searches faster.

Thank you for your help.