728x90
반응형
풀이 :
반복되는 음절 찾기 -> String.substring(_, _) 사용
Code
public class Solution2007 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int tc = 1; tc <= n; tc++) {
String str = sc.next();
for (int i = 1; i <= 10; i++) {
if (str.substring(0, i).equals(str.substring(i, i + i))) {
System.out.printf("#%d %d\n", tc, i);
break;
}
}
}
}
}
728x90
반응형
'SWEA' 카테고리의 다른 글
swea 1208 [D3] [S/W 문제 해결 기본] 1일차 - Flatten JAVA (1) | 2023.11.22 |
---|---|
swea 1206 [D3] [S/W 문제 해결 기본] 1일차 - View JAVA (1) | 2023.11.22 |
swea 2005 [D2] 파스칼의 삼각형 JAVA (0) | 2023.11.22 |
swea 2001 [D2] 파리 퇴치 JAVA (0) | 2023.11.22 |
swea 1989 [D2] 초심자의 회문 검사 JAVA (0) | 2023.11.22 |