Sets

Learn to create sets, add and remove elements, handle duplicates, and work with mutable sets.

Introduction

We use sets instead of lists when:

  • We want to ensure that elements in our collection are unique (sets keep only unique elements).

  • We frequently look for an element in a collection (finding ...