I read online that HashSet uses HashMap as its underlying data structure.
And HashMap uses ArrayList as its underlying data structure with each item in the list being an object of LinkedList or a tree.
What is the time complexity when you initialize a HashSet this way? Can it be O(1)? If not, why?
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(3);
list.add(2);
list.add(6);
list.add(0);
HashSet<Integer> set = new HashSet<>(list);