Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bronze II] Title: 팰린드롬인지 확인하기, Time: 128 ms, Memory: 9336 KB -Baekjo…
…onHub
- Loading branch information
1 parent
d2f29ba
commit 35f4400
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |