728x90
https://swexpertacademy.com/main/solvingProblem/solvingProblem.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com

import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int tc=1;tc<=10;tc++) {
int num = sc.nextInt();
String target= sc.next();
String sentence=sc.next();
int length=sentence.length()-sentence.replace(target, "").length();
System.out.println("#"+tc+" "+length/target.length());
}
}
}
replace를 잘 활용하자
728x90
'SW Expert Academy > SWEA D3' 카테고리의 다른 글
| [SW Expert Academy] 홀수일까 짝수일까 (D3) (0) | 2024.09.02 |
|---|---|
| [S/W 문제해결 기본] 8일차 - 암호문3 (D3) (4) | 2024.09.02 |
| [SW Expert Academy] 직사각형 길이 찾기 (D3) (0) | 2024.09.01 |
| [SW Expert Academy] [S/W 문제해결 기본] 5일차 - Magnetic (D3) (1) | 2024.09.01 |
| [SW Expert Academy] [S/W 문제해결 기본] 7일차 - 암호생성기 (D3) (1) | 2024.09.01 |