참여 난이도
자바/미들러
오늘의 문제
백준 9996 한국이 그리울 땐 서버에 접속하지

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = Integer.parseInt(sc.nextLine());
String pattern = sc.nextLine();
String[] split = pattern.split("\\*");
String prefix = split[0];
String suffix = split[1];
for (int i = 0; i < N; i++) {
String filename = sc.nextLine();
if (filename.length() < prefix.length() + suffix.length()) {
System.out.println("NE");
continue;
}
boolean startsWith = filename.startsWith(prefix);
boolean endsWith = filename.endsWith(suffix);
if (startsWith && endsWith) {
System.out.println("DA");
} else {
System.out.println("NE");
}
}
sc.close();
}
}
'자료구조 & 알고리즘 관련 > 99클럽 코딩테스트 스터디 6기' 카테고리의 다른 글
99클럽 코테 스터디 7일자 TIL [04/08] (0) | 2025.04.09 |
---|---|
99클럽 코테 스터디 5일자 TIL [04/04] (0) | 2025.04.05 |
99클럽 코테 스터디 4일자 TIL [04/03] (0) | 2025.04.03 |
99클럽 코테 스터디 3일자 TIL [04/02] (0) | 2025.04.02 |
99클럽 코테 스터디 2일자 TIL [04/01] (0) | 2025.04.01 |
참여 난이도
자바/미들러
오늘의 문제
백준 9996 한국이 그리울 땐 서버에 접속하지

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = Integer.parseInt(sc.nextLine());
String pattern = sc.nextLine();
String[] split = pattern.split("\\*");
String prefix = split[0];
String suffix = split[1];
for (int i = 0; i < N; i++) {
String filename = sc.nextLine();
if (filename.length() < prefix.length() + suffix.length()) {
System.out.println("NE");
continue;
}
boolean startsWith = filename.startsWith(prefix);
boolean endsWith = filename.endsWith(suffix);
if (startsWith && endsWith) {
System.out.println("DA");
} else {
System.out.println("NE");
}
}
sc.close();
}
}
'자료구조 & 알고리즘 관련 > 99클럽 코딩테스트 스터디 6기' 카테고리의 다른 글
99클럽 코테 스터디 7일자 TIL [04/08] (0) | 2025.04.09 |
---|---|
99클럽 코테 스터디 5일자 TIL [04/04] (0) | 2025.04.05 |
99클럽 코테 스터디 4일자 TIL [04/03] (0) | 2025.04.03 |
99클럽 코테 스터디 3일자 TIL [04/02] (0) | 2025.04.02 |
99클럽 코테 스터디 2일자 TIL [04/01] (0) | 2025.04.01 |