image_2021-11-01_03-04-37.png
37.5 KB
#N1207. Unique Number of Occurrences
problem link=>https://leetcode.com/problems/unique-number-of-occurrences/
#solution
problem link=>https://leetcode.com/problems/unique-number-of-occurrences/
#solution
class Solution {
public boolean uniqueOccurrences(int[] arr) {
int[] occur=new int[2001];
for(int num:arr){
occur[1000+num]++;
}
Arrays.sort(occur);
for(int i=0; i<occur.length-1; i++){
if(occur[i]==occur[i+1]&&occur[i]!=0)
return false;
}
return true;
}
}