package leetcode;

/**
 * https://leetcode.com/problems/unique-number-of-occurrences/
 */
public class Problem1207 {
    public boolean uniqueOccurrences(int[] arr) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1207 prob = new Problem1207();
        System.out.println(prob.uniqueOccurrences(new int[]{1, 2, 2, 1, 1, 3})); // true
        System.out.println(prob.uniqueOccurrences(new int[]{1, 2})); // false
        System.out.println(prob.uniqueOccurrences(new int[]{-3, 0, 1, -3, 1, 1, 1, -3, 10, 0})); // true
    }
}

package leetcode;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * https://leetcode.com/problems/unique-number-of-occurrences/
 */
public class Problem1207 {
    public boolean uniqueOccurrences(int[] arr) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            if (!map.containsKey(arr[i])) {
                map.put(arr[i], 0);
            } else {
                map.put(arr[i], map.get(arr[i]) + 1);
            }
        }
        Set<Integer> set = new HashSet<>();
        for (int count : map.values()) {
            if (!set.add(count)) {
                return false;
            }
        }
        return true;
    }
}

Solve problem 1207