How to remove duplicates from List?
(a) HashSet<String> listToSet = new HashSet<String>(duplicateList);
(b) HashSet<String> listToSet = duplicateList.toSet();
(c) HashSet<String> listToSet = Collections.convertToSet(duplicateList);
(d) HashSet<String> listToSet = duplicateList.getSet();
The question was asked in an international level competition.
This is a very interesting question from Data Structures-List in portion java.util – The Collections Framework of Java