BackeasyHashing Infosys

Galactic Mineral Scanner Solution

Problem Statement

Given a list of mineral frequencies, write a function to determine the count of distinct minerals.

Example 1
Input
[1, 2, 3, 2, 1]
Output
3

Explanation: Step-by-step: with input [1, 2, 3, 2, 1], we convert the list to a set to remove duplicates, resulting in {1, 2, 3}. The size of the set is 3, giving output 3.

Example 2
Input
[1, 1, 1, 1, 1]
Output
1

Explanation: Step-by-step: with input [1, 1, 1, 1, 1], we convert the list to a set to remove duplicates, resulting in {1}. The size of the set is 1, giving output 1.

Constraints

  • 1 <= s.length <= 10^5
  • s consists of only lowercase English letters.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free