83. Unique Tallies
During a football season, every goal is recorded by writing down the id of the player who scored it, producing the array nums in match order. The tally of a player is the number of goals credited to that id. The league wants to give out a trophy for every distinct tally level, and that only works if no two scoring players ended with the same tally.
Return true if the tallies of all distinct ids in nums are pairwise different, and false if at least two ids share the same tally.
Example 1
- Input:
- nums = [3,3,5,8,8,8]
- Output:
- true
- Explanation:
Player 3 scored 2 goals, player 5 scored 1 and player 8 scored 3; the tallies 2, 1, 3 are all different.
Example 2
- Input:
- nums = [1,2,2,3,3]
- Output:
- false
- Explanation:
Player 1 has 1 goal while players 2 and 3 both have 2, so two tallies coincide.
Constraints
1 ≤ nums.length ≤ 105
-109 ≤ nums[i] ≤ 109
How this problem is judged
- Answers
- Your answer must match exactly. Numbers compare by value, so 2 and 2.0 are equal.
Expected complexity
- Time
- O(n)
- Space
- O(n)