美团笔试 时间复杂度太高本来想用集合省时间结果只过了%10
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] array = new int[n];
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i=0;i<n;i++){
array[i] = sc.nextInt();
list.add(array[i]);
}
HashSet<String> set = new HashSet<String>();
for(int i=0;i<n;i++){
int temp = list.get(i);
list.remove(i);
for(int j=0;j<n-1;j++){
String str = temp+""+list.get(j);
set.add(str);
}
list.add(i,temp);
}
int len = set.size();
int[] aim = new int[len];
Iterator<String> it = set.iterator();
int num = 0;
while(it.hasNext()){
aim[num] = Integer.parseInt(it.next());
num++;
}
int count = 0;
for(int i=0;i<len;i++){
if(aim[i]%7==0){
count++;
}
}
System.out.println(count);
}
}