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):
<
If the order of the final solution is irrelevant, you could break the array into smaller arrays based on length of the strings, and then remove duplicates from those arrays. Example:
// You have
{"a", "ab", "b", "ab", "a", "c", "cd", "cd"},
// you break it into
{"a", "b", "a", "c"} and {"ab", "ab", "cd", "cd"},
// remove duplicates from those arrays using the merge method that others have mentioned,
// and then combine the arrays back together into
{"a", "b", "c", "ab", "cd"}