Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

There is a bag of balls with different types of colours. You have to find out the Total number of different types of colors of

There is a bag of balls with different types of colours. You have to find out the Total number of different types of colors of ball present in the bags. Bag of balls will be represented as an array 'A' containing integers 'Ai'. Different values of Ai represents different colors. Example 1: There is a bag containing the following balls : 1,2,1,1,3,3,5. Now the types of colors present in the bags are 1,2,3,5 so the number of Types of colours are 4 so answer is 4. Example 2: There is a bag containing the following balls : 2,9,2,9,5,5,5. Now the types of colors present in the bags are 2,9,5 so the number of Types of colours are 3 so answer is 3.
Input Format
The first line will contain an integer n which is the length of array 'A'. The second line will contain n space seperated integers representing the elements of array 'A'
Constraints
0< n <=100000,0< Ai <10
Output Format
Print a single line containing the integer representing the numbers of colors of balls present in the bag.
Sample Input 0
5
15454
Sample Output 0
3
Explanation 0
The different types of colors present in the array are 1,5,4 so there are only 3 types of colors.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions