160. 7의 개수

김해준's avatar
Dec 30, 2025
160. 7의 개수

사용언어 : Java

문제
notion image
풀이
/* 각 배열의 원소마다 %10해서 한자리씩 7인지 비교 100 * 7(100000 % 10 = 7번) */ class Solution { public int solution(int[] array) { int temp = 0; int answer = 0; for(int i = 0 ; i < array.length; i++) { temp = array[i]; System.out.println(temp); while(temp > 0) { int cur = temp % 10; System.out.println(cur); if(cur == 7)answer++; temp /= 10; } } return answer; } }
notion image
Share article