public int solution(int[] a) {
        int counter[] = new int[a.length];

        for (int i = 0; i<a.length; i++){
            if (a[i] < 1 || a[i] > a.length){
                return 0;
            }
            else if (counter[a[i]-1] == 1){
                return 0;
            }
            else{
                counter[a[i]-1] += 1;
            }
        }
        return 1;
    }