easyHashingPattern: Frequency Map
Count Unique Frequencies Solution
Problem Statement
You are given a list of integers representing mineral frequencies. Determine the count of distinct minerals in the list.
Examples
Example 1:
Input:[1, 2, 3, 2, 1]
Output:3
Explanation: There are 3 unique minerals: 1, 2, and 3.
Example 2:
Input:[4, 4, 4, 4]
Output:1
Explanation: There is 1 unique mineral: 4.
Constraints
- 1 <= s.length <= 10^5
- s consists of only lowercase English letters.
Time: O(N) Space: O(1)
The optimized approach would involve using a hash set to store unique minerals, resulting in a time complexity of O(n).
Run, Test & Submit Code
Ready to practice this challenge? Launch our interactive compilation environment with compiler validation.
Solve on Interactive WorkspaceTested Solutions
No solution code is currently loaded.
Complete this code in the workspace editor.
