✔ 나의 답-> 성공
import java.util.*;
public class Main {
public static String solution(String input){
input = input.toUpperCase();
String output ="";
for(int i = input.length()-1; i>=0;i--){
output+=String.valueOf(input.charAt(i));
}
if(output.equals(input))
return "YES";
else
return "NO";
}
public static void main(String[] args){
Scanner kb = new Scanner(System.in);
String input = kb.next();
System.out.println(solution(input));
}
}
✔️ 강의 답
1)
import java.util.*;
public class p7 {
public static String solution(String str) {
str=str.toUpperCase();
String answer="YES";
int len = str.length();
for(int i=0;i<len/2;i++) {
if(str.charAt(i)!=str.charAt(len-1-i)) return "NO";
}
return answer;
}
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String str = kb.next();
System.out.println(solution(str));
}
}
2)
import java.util.*;
public class p7 {
public static String solution(String str) {
String answer="NO";
String tmp = new StringBuilder(str).reverse().toString();
if(str.equalsIgnoreCaser(tmp)) answer="YES";
return answer
}
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String str = kb.next();
System.out.println(solution(str));
}
}