-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoundrobinString.java
More file actions
32 lines (29 loc) · 1.1 KB
/
RoundrobinString.java
File metadata and controls
32 lines (29 loc) · 1.1 KB
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
32
package algorithm.string;
import java.util.Scanner;
/**
* 앞에서 읽을 때나 뒤에서 읽을 때나 같은 문자열을 회문 문자열이라고 합니다.
* 문자열이 입력되면 해당 문자열이 회문 문자열이면 "YES", 회문 문자열이 아니면 “NO"를 출력 하는 프로그램을 작성하세요.
* 단 회문을 검사할 때 대소문자를 구분하지 않습니다.
*
* 입력설명
* 첫 줄에 길이 100을 넘지 않는 공백이 없는 문자열이 주어집니다.
*
* 출력설명
* 첫 번째 줄에 회문 문자열인지의 결과를 YES 또는 NO로 출력합니다.
*/
class RoundrobinString {
public static void main(String[] args) {
RoundrobinString T = new RoundrobinString();
Scanner kb = new Scanner(System.in);
String str = kb.next();
System.out.print(T.solution(str));
}
public String solution(String str) {
String answer = "NO";
String tmp = new StringBuilder(str).reverse().toString();
if (str.equalsIgnoreCase(tmp)) {
answer = "YES";
}
return answer;
}
}