← 返回 google 的题目列表Partition Numbers by Distinct Frequencies
类型:online_judge
Given an integer array nums, all occurrences of the same value must belong to the same partition.
Each distinct value forms exactly one partition, whose size equals that value's frequency in the original array. Determine whether the array can be partitioned such that no two different partitions have the same size.
Equivalently, determine whether the frequencies of all distinct values in nums are pairwise distinct.
Example 1:
Input: nums = [1, 2, 3, 4, 2, 3, 3, 4, 4, 4]
Output: true
Explanation:
The frequencies of 1, 2, 3, and 4 are 1, 2, 3, and 4 respectively.
All partition sizes are distinct.
Example 2:
Input: nums = [1, 2, 3]
Output: false
Explanation: 1, 2, and 3 all occur once, so multiple partitions have size 1.
Constraints:
1 <= len(nums) <= 200,000
nums[i] is an integer.
Example
Input
10
1 2 3 4 2 3 3 4 4 4
Output
true