020-002-004

Set Basics: Collection Without Duplicates

Easy

Problem Description

Set Basics: collection Without Duplicates

In this problem, you will create a program that adds multiple numbers to a HashSet to remove duplicates and displays the count of unique elements to standard output.

Learning Objective: Understand how to create a collection without duplicates using HashSet

Overview

Input multiple numbers and output the count of unique elements using HashSet.

Specifications

  • Add numbers to HashSet
  • Duplicates are automatically removed
  • Output the final element count

Input

Line 1: Number of elements
Following lines: Each number

Output Format

Unique count: 3

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up