• 카테고리

    질문 & 답변
  • 세부 분야

    알고리즘 · 자료구조

  • 해결 여부

    미해결

오답이 아닌데 오답인 이유 ..

22.01.14 23:43 작성 조회수 194

0

import java.util.Scanner;

public class Main {

public int solution(String[] str, char word){
int count =0;

for (String s : str) {
if (s.toLowerCase().charAt(0)==word){
count++;
}
}

return count;
}
public static void main(String[] args) {
Main ch = new Main();
Scanner sc = new Scanner(System.in);

String[] str = sc.nextLine().split("");
char word = sc.nextLine().charAt(0);

System.out.println(ch.solution(str, word));
}
}

위 풀이가 왜 오답이라고 나오는건가요? ..

풀이도 정해져있나요? 

 

 

답변 1

답변을 작성해보세요.

1

pcc2242님의 프로필

pcc2242

2022.01.15

word가 대문자로 들어올 경우도 생각해주셔야 할 것 같습니다.