프로그래밍언어 (17) 썸네일형 리스트형 프로그래머스 LV.0 2023-02-13 7의 갯수 class Solution { public int solution(int[] array) { int answer = 0; final char ch = '7'; for(int a : array){ String s = Integer.toString(a); for(int i = 0; i < s.length(); i++){ if(s.charAt(i) == ch){ answer++; } } } return answer; } } 설명 배열에 담긴 각 요소에 7의 갯수를 구한다. [7, 77, 17]의 경우 7의 갯수는 4개이다. 본 풀이는 int형과 String형 변환을 활용해 풀이를 했다. Integer.toString(int i)는 i를 문자열로 변환하며 각 문자열에 문자를 순회하.. 이전 1 2 3 다음