Skip to content

Commit

Permalink
[Bronze II] Title: 팰린드롬인지 확인하기, Time: 128 ms, Memory: 9336 KB -Baekjo…
Browse files Browse the repository at this point in the history
…onHub
  • Loading branch information
quokka-eating-carrots committed Feb 28, 2023
1 parent d2f29ba commit 35f4400
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
28 changes: 28 additions & 0 deletions 백준/Bronze/10988. 팰린드롬인지 확인하기/README.md
@@ -0,0 +1,28 @@
# [Bronze II] 팰린드롬인지 확인하기 - 10988

[문제 링크](https://www.acmicpc.net/problem/10988)

### 성능 요약

메모리: 9336 KB, 시간: 128 ms

### 분류

구현(implementation), 문자열(string)

### 문제 설명

<p>알파벳 소문자로만 이루어진 단어가 주어진다. 이때, 이 단어가 팰린드롬인지 아닌지 확인하는 프로그램을 작성하시오.</p>

<p>팰린드롬이란 앞으로 읽을 때와 거꾸로 읽을 때 똑같은 단어를 말한다. </p>

<p>level, noon은 팰린드롬이고, baekjoon, online, judge는 팰린드롬이 아니다.</p>

### 입력

<p>첫째 줄에 단어가 주어진다. 단어의 길이는 1보다 크거나 같고, 100보다 작거나 같으며, 알파벳 소문자로만 이루어져 있다.</p>

### 출력

<p>첫째 줄에 팰린드롬이면 1, 아니면 0을 출력한다.</p>

@@ -0,0 +1,14 @@
var fs = require("fs");
const filePath = process.platform === "linux" ? "/dev/stdin" : "test.txt";
let input = fs.readFileSync(filePath).toString().trim();
const length = input.length
for (let i = 0; i < length / 2; i += 1) {
if (input[i] !== input[length - 1 - i]) {
return console.log(0)
}
if (i === Math.floor(length / 2) && length % 2 !== 0) {
return console.log(1)
} else if (i === length / 2 - 1 && length % 2 === 0) {
return console.log(1)
}
}

0 comments on commit 35f4400

Please sign in to comment.