[Coding Test] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค -๊ฐ€์šด๋ฐ ๊ธ€์ž ๊ฐ€์ ธ์˜ค๊ธฐ-

๐Ÿ“ƒ๋ฌธ์ œ ๋งํฌ

https://school.programmers.co.kr/learn/courses/30/lessons/12903

๐Ÿคจ์ƒ๊ฐํ•˜๊ธฐ

๋ฌธ์ œ ๊ทธ๋Œ€๋กœ ๊ตฌํ˜„

๐Ÿ˜Ž๋‚ด ํ’€์ด

1
2
3
4
5
6
7
8
9
10
11
function solution(s) {
if (s.length % 2 === 0) {
return s.substring(
Math.floor(s.length / 2) - 1,
Math.floor(s.length / 2) + 1,
)
} else {
return s.substring(Math.floor(s.length / 2), Math.floor(s.length / 2) + 1)
}
// ์†Œ์ˆ˜์  ์ œ๊ฑฐ๋ฅผ ์œ„ํ•œ floor ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ
}

[Coding Test] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค -๊ฐ€์šด๋ฐ ๊ธ€์ž ๊ฐ€์ ธ์˜ค๊ธฐ-
http://example.com/2022/11/16/Coding-Test-Programmers-3/
Author
Elio
Posted on
November 16, 2022
Licensed under