Today at school the teacher asked us to implement a duplicate-deletion algorithm. It\'s not that difficult, and everyone came up with the following solution (pseudocode):
<
This is the shortest algorithm that worked where arrNames and arrScores is parallel arrays and the highest score is taken.
I := 0;
J := 0;
//iCount being the length of the array
for I := 1 to iCount do
for J := I + 1 to iCount do
if arrNames[I] = arrNames[J] then
begin
if arrScores[I] <= arrScores[J] then
arrScores[I] := arrScores[J];
arrScores[J] := arrScores[iCount];
arrNames[J] := arrNames[iCount];
arrScores[iCount] := 0;
arrNames[iCount] := '';
Dec(iCount);
end;