01-08 08:57
Recent Posts
Recent Comments
๊ด€๋ฆฌ ๋ฉ”๋‰ด

miinsun

[Algorithm]์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ž๋ฐ”_7 ํšŒ๋ฌธ ๋ฌธ์ž์—ด ๋ณธ๋ฌธ

Algorithm/Java

[Algorithm]์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ž๋ฐ”_7 ํšŒ๋ฌธ ๋ฌธ์ž์—ด

miinsun 2022. 1. 2. 23:14

 

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช…

์•ž์—์„œ ์ฝ์„ ๋•Œ๋‚˜ ๋’ค์—์„œ ์ฝ์„ ๋•Œ๋‚˜ ๊ฐ™์€ ๋ฌธ์ž์—ด์„ ํšŒ๋ฌธ ๋ฌธ์ž์—ด์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.
๋ฌธ์ž์—ด์ด ์ž…๋ ฅ๋˜๋ฉด ํ•ด๋‹น ๋ฌธ์ž์—ด์ด ํšŒ๋ฌธ ๋ฌธ์ž์—ด์ด๋ฉด "YES", ํšŒ๋ฌธ ๋ฌธ์ž์—ด์ด ์•„๋‹ˆ๋ฉด “NO"๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์„ธ์š”.
๋‹จ ํšŒ๋ฌธ์„ ๊ฒ€์‚ฌํ•  ๋•Œ ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

โ€‹

๐Ÿ”จ ์ž…์ถœ๋ ฅ ์˜ˆ

์ž…๋ ฅ - ์ฒซ ์ค„์— ๊ธธ์ด 100์„ ๋„˜์ง€ ์•Š๋Š” ๊ณต๋ฐฑ์ด ์—†๋Š” ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค.

gooG

์ถœ๋ ฅ - ์ฒซ ๋ฒˆ์งธ ์ค„์— ํšŒ๋ฌธ ๋ฌธ์ž์—ด์ธ์ง€์˜ ๊ฒฐ๊ณผ๋ฅผ YES ๋˜๋Š” NO๋กœ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

YES
 

โ€‹

๐Ÿ’ป Solution.java

import java.util.Scanner;
  
public class Main {
	public String solution(String str) {
		str = str.toLowerCase();
		
		for(int i = 0; i < str.length() / 2; i++) {
			if(str.charAt(i) != str.charAt(str.length() - 1 - i)) {
				return "NO";
			}
		}
		return "YES";
	}
	
	public static void main(String[] args){
		Main main  = new Main();
		Scanner sc =new Scanner(System.in);
		String str = sc.next();
		
		System.out.println(main.solution(str));
		sc.close();
		return ;
	}
}

 

Comments