class Solution {
public int answer = 0;
public boolean[] visit;
public int solution(int[] nums) {
visit = new boolean[nums.length];
recur(0, 0, nums, 0);
return answer;
}
public void recur(int count, int start, int[] nums, int sum) {
if(count==3) {
if(isPrime(sum)) { answer++; }
return;
}
for(int i=start; i<nums.length; i++) {
if(visit[i]) { continue; }
visit[i] = true;
recur(count+1, i+1, nums, sum+nums[i]);
visit[i] = false;
}
}
public boolean isPrime(int n) {
if(n==1) { return false; }
for(int i=2; i*i<=n; i++) {
if(n%i==0) { return false; }
}
return true;
}
}