Skip to content

Commit 0635c3c

Browse files
committed
[level 1] Title: 가운데 글자 가져오기, Time: 0.02 ms, Memory: 76.4 MB -BaekjoonHub
1 parent 3fe44ed commit 0635c3c

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

프로그래머스/1/12903. 가운데 글자 가져오기/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# [level 1] 가운데 글자 가져오기 - 12903
22

3-
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12903?language=java)
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12903)
44

55
### 성능 요약
66

7-
메모리: 73.9 MB, 시간: 0.02 ms
7+
메모리: 76.4 MB, 시간: 0.02 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2026년 06월 22일 07:37:18
19+
2026년 06월 24일 09:32:58
2020

2121
### 문제 설명
2222

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class Solution {
22
public String solution(String s) {
3-
if (s.length() % 2 == 0) return s.substring(s.length()/2-1, s.length()/2+1);
4-
else return s.substring(s.length()/2, s.length()/2+1);
3+
int n = s.length();
4+
if (n % 2 == 0) return s.substring(n/2-1, n/2+1);
5+
else return s.substring(n/2, n/2+1);
56
}
67
}

0 commit comments

Comments
 (0)