๋ด ํ์ด
ํต์ฌ์ ๋ฌธ์์ด์ ๊ธธ์ด๋งํผ์ / 2 ํ ๋ค, ๋ฐ์ผ๋ก ์ ๋๋ค๊ณ ์๊ฐํ๋ฉด ๋๋ค.
๊ทธ๋ฆฌ๊ณ ๋น๊ตํด์ ํฐ๋ฆฐ๋๋กฌ์ ๊ฒ์ฌํ๋ฉด ๋๋ค.
package baekjoon.solved_Tier.bronze1;
import java.util.Arrays;
import java.util.Scanner;
@SuppressWarnings("SpellCheckingInspection")
public class Prob03_Palindrom {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while(true) {
char[] arr = input.nextLine().toCharArray();
if(arr.length == 1) {
if(arr[0] - '0' == 0) break;
else {
System.out.println("yes");
}
}
int mid = arr.length / 2;
for (int i = 0; i < mid; i++) {
int start = arr[i] - '0';
int reverse = arr[(arr.length - 1) - i] - '0';
if(start != reverse) {
System.out.println("no");
break;
}
if(i == mid - 1) {
System.out.println("yes");
}
}
}
}
}
๋๊ธ