
8일차 문제
링크 : https://www.acmicpc.net/problem/9996
문제 풀이
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
String pattern = br.readLine();
String[] arr = new String[N];
for(int i=0; i<N; i++) {
arr[i] = br.readLine();
}
String patternArr[] = pattern.split("\\*");
String prefix = patternArr[0];
String suffix = patternArr[1];
for(int i=0; i<N; i++) {
String str = arr[i];
// 패턴보다 짧은 문자열은 매칭 불가능
if(str.length() < pattern.length()-1) {
System.out.println("NE");
continue;
}
if(str.startsWith(prefix) && str.endsWith(suffix)) {
System.out.println("DA");
} else {
System.out.println("NE");
}
}
}
}'Study > 99클럽 코테 스터디' 카테고리의 다른 글
| [99클럽 코테 스터디 10일차 TIL] 병든 나이트 (0) | 2025.04.11 |
|---|---|
| [99클럽 코테 스터디 9일차 TIL] 저울 (1) | 2025.04.10 |
| [99클럽 코테 스터디 7일차 TIL] 쇠막대기 (0) | 2025.04.08 |
| [99클럽 코테 스터디 6일차 TIL] 섬의 개수 (0) | 2025.04.07 |
| [99클럽 코테 스터디 5일차 TIL] 수열 (0) | 2025.04.04 |