중복된 숫자 개수
📃 문제
🔨 풀이
1
2
3
4
5
6
7
8
9
class Solution {
public int solution(int[] array, int n) {
int answer = 0;
for(int i=0; i<array.length; i++){
if(array[i]==n) answer ++;
}
return answer;
}
}
array배열의 크기까지 for문을 돌림
만약 array의 i번째 수와 n이 같다면
answer에 1을 더함
This post is licensed under CC BY 4.0 by the author.