I am looking for an efficient way to detect the number of unique values in an array.
My current approach:
- Quicksort array of integers
- Then run a loop to compare elements.
In code:
yearHolder := '';
for I := 0 to High(yearArray) do
begin
currYear := yearArray[i];
if (yearHolder <> currYear) then
begin
yearHolder := currYear;
Inc(uniqueYearNumber);
end;
end;