remove duplicates without using set. still O(n^2)