Skip to content

Commit 9c2f75f

Browse files
committed
[level 1] Title: 수박수박수박수박수박수?, Time: 2.07 ms, Memory: 76.8 MB -BaekjoonHub
1 parent 97b8a7f commit 9c2f75f

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# [level 1] 수박수박수박수박수박수? - 12922
2+
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12922)
4+
5+
### 성능 요약
6+
7+
메모리: 76.8 MB, 시간: 2.07 ms
8+
9+
### 구분
10+
11+
코딩테스트 연습 > 연습문제
12+
13+
### 채점결과
14+
15+
정확성: 100.0<br/>합계: 100.0 / 100.0
16+
17+
### 문제 설명
18+
19+
<p>길이가 n이고, "수박수박수박수...."와 같은 패턴을 유지하는 문자열을 리턴하는 함수, solution을 완성하세요. 예를들어 n이 4이면 "수박수박"을 리턴하고 3이라면 "수박수"를 리턴하면 됩니다.</p>
20+
21+
<h5>제한 조건</h5>
22+
23+
<ul>
24+
<li>n은 길이 10,000이하인 자연수입니다.</li>
25+
</ul>
26+
27+
<h5>입출력 예</h5>
28+
<table class="table">
29+
<thead><tr>
30+
<th>n</th>
31+
<th>return</th>
32+
</tr>
33+
</thead>
34+
<tbody><tr>
35+
<td>3</td>
36+
<td>"수박수"</td>
37+
</tr>
38+
<tr>
39+
<td>4</td>
40+
<td>"수박수박"</td>
41+
</tr>
42+
</tbody>
43+
</table>
44+
45+
> 출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public String solution(int n) {
3+
String answer = "";
4+
for(int i=0; i<n; i++){
5+
if(i%2==0){
6+
answer+="수";
7+
}else{
8+
answer+="박";
9+
}
10+
}
11+
return answer;
12+
}
13+
}

0 commit comments

Comments
 (0)