Use Set to decide weather to add to ArrayList
Pass the time limit.
O(N^2) time complexity