본문 바로가기
Beakjoon&프로그래머스/Java

[백준/Java] 29766번 DKSH 찾기

by 현장 2023. 10. 6.

- Code

package com.in28minutes.learnspringframework;

import java.util.Scanner;

public class _29766 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int res = 0;

        for (int i = 0; i < line.length() - 3; i++) {
            String s = line.substring(i, i + 4);
            if (s.equals("DKSH")) {
                res++;
            }
        }

        System.out.println(res);
    }
}