๋ฉํ ๋ง ๋ฌธ์ 4์คfor๋ฌธ
public int solution(int student, int test, int[][] arr) { int answer = 0; //(1๋ฒํ์~4๋ฒํ์๊น์ง ์ฐจ๋ก๋ก ๊ตฌํ๊ธฐ) for (int i=0; i list = new ArrayList(); for(int j = 0; jindex){ //๊ฐ ์ํ(ํ)์์ ๋ฉํ ์ ๋ฑ์๋ณด๋ค ๋ฎ์ ํ์๋ค ๋ฃ๊ธฐ list.add(arr[j][k]); } } if(index == student-1) { //๊ผด๋ฑ์ ํ๋ฒ์ด๋ผ๋ ํ์ ์์ผ๋ฉด ๋ฉํ ๊ฐ ๋ ์ ์์ด clear list.clear(); } } //list : ๋ฉํ ๋ค ๋ฑ์ ์ธ ํ์ ๋ชจ์(์ค๋ณต O) //์ค๋ณต์ ๊ฑฐ ํ ํ์๋ณ๋ก list์์ ์ํ ๊ฐฏ์(M) ๋งํผ ์๋ ํ์๋ง ์นด์ดํธ. answer += list.stream().distinct() .filter(integer -> Collections.frequency(list, integer) == test) .count(); } return answer; }