Many problems ask "have I seen this before?", such as finding duplicates or counting distinct values. A Set keeps only unique elements and answers contains in O(1) average with HashSet. Use TreeSet when you also need sorted order or the next bigger value, and LinkedHashSet when insertion order matters. If you need a count per value rather than just presence, use a Map instead.