I need to find elements from an array that are unique.
The program is supposed to identify the duplicate elements as they are being entered and not count them.
For example: if I enter 10 then 20 then 15 then 10 then 20. The program is supposed to identify only the unique numbers in this case 15
I tried to use a linear search method like the one below but this will only compare the elements against one key
public class LinearSearch{
public static in linearSearch(int[] list, int key){
for (int i = 0; i < list.lenght; i++){
if(key == list [i])
return i;
}
return -1:
}
}