Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 문제해결
- 프로그래머스
- oracle
- 투포인터
- SQL
- priorityqueue
- SWEA
- 운동기록
- math
- 알고리즘
- 자바
- MySQL
- 시뮬레이션
- binary search
- db
- BFS
- BOJ
- 코딩테스트
- 코테
- 문제풀이
- 건강
- greedy
- 문자열
- dfs
- Java
- COS PRO
- DP
- 백준
- 이분탐색
- 러닝일지
Archives
- Today
- Total
슈콩
[SWEA] 회문의 회문 본문

[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AY2hjCWKbykDFATh
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
static String str;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
str = br.readLine();
boolean result = false;
if(str.length()%2==0) {
if(check(0,str.length()) && check(0,str.length()/2) && check(str.length()/2,str.length())) {
result = true;
}
}
else {
if(check(0,str.length()) && check(0,str.length()/2) && check(str.length()/2+1,str.length())) {
result = true;
}
}
if(result)
System.out.println("#"+tc+" YES");
else
System.out.println("#"+tc+" NO");
}
}
private static boolean check(int start,int end) {
for(int i=start;i<(end-start)/2;i++) {
if(str.charAt(start+i)!=str.charAt(end-1-i))
return false;
}
return true;
}
}