Lesson4 - PermCheck

作成日:2018/4/4
Task Score: 58%
Correctness: 100%
Performance: 16%
PermCheck coding task - Learn to Code - Codility

// you can also use imports, for example:
// import java.util.*;

// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");

import java.util.*;

class Solution {
    public int solution(int[] A) {
        // write your code in Java SE 8

        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int num : A){
            if (!list.contains(num)) {
                list.add(num);
            } else {
                return 0;
            }
            if (num > A.length) {
                return 0;
            }
        }

        return 1;
    }
}