Deep_Lee

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV14P0c6AAUCFAYi&categoryId=AV14P0c6AAUCFAYi&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=2#none 

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

 

 


์ฐพ์„ ๋ฌธ์ž์—ด์—์„œ ๊ฒ€์ƒ‰์–ด๊ฐ€ ์žˆ์œผ๋ฉด ์ˆ˜๋งŒ ์„ธ๋ฉด๋˜๋‹ˆ๊นŒ, replaceAll์ด์šฉํ•˜์—ฌ ๊ฒ€์ƒ‰์–ด๋ฅผ *๋กœ ๋Œ€์ฒดํ•˜๊ณ 

*๋ฅผ ์นด์šดํŒ…ํ•จ.

 

 

 

import java.util.Scanner;
class Solution{
    public static void main(String args[]) throws Exception {
        Scanner kb = new Scanner(System.in);
        int[] answer=new int[10];
        int cnt=0;
        for(int test_case=0; test_case<10; test_case++){
            int n=kb.nextInt();
            String s=kb.next();
            String f=kb.next();
            f=f.replaceAll(s,"*");
            for(char x:f.toCharArray()){
                if(x=='*')
                    cnt++;
            }
            answer[test_case]=cnt;
            cnt=0;
        }
        for(int i=0; i<answer.length; i++) System.out.println("#"+(i+1)+" "+answer[i]);
 
    }
}