Skip to content

Commit 3085122

Browse files
[level 1] Title: 이상한 문자 만들기, Time: 0.25 ms, Memory: 33.5 MB -BaekjoonHub
1 parent 71bdbd9 commit 3085122

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# [level 1] 이상한 문자 만들기 - 12930
2+
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12930)
4+
5+
### 성능 요약
6+
7+
메모리: 33.5 MB, 시간: 0.25 ms
8+
9+
### 구분
10+
11+
코딩테스트 연습 > 연습문제
12+
13+
### 채점결과
14+
15+
정확성: 100.0<br/>합계: 100.0 / 100.0
16+
17+
### 제출 일자
18+
19+
2024년 12월 24일 14:19:21
20+
21+
### 문제 설명
22+
23+
<p>문자열 s는 한 개 이상의 단어로 구성되어 있습니다. 각 단어는 하나 이상의 공백문자로 구분되어 있습니다. 각 단어의 짝수번째 알파벳은 대문자로, 홀수번째 알파벳은 소문자로 바꾼 문자열을 리턴하는 함수, solution을 완성하세요.</p>
24+
25+
<h5>제한 사항</h5>
26+
27+
<ul>
28+
<li>문자열 전체의 짝/홀수 인덱스가 아니라, 단어(공백을 기준)별로 짝/홀수 인덱스를 판단해야합니다.</li>
29+
<li>첫 번째 글자는 0번째 인덱스로 보아 짝수번째 알파벳으로 처리해야 합니다.</li>
30+
</ul>
31+
32+
<h5>입출력 예</h5>
33+
<table class="table">
34+
<thead><tr>
35+
<th>s</th>
36+
<th>return</th>
37+
</tr>
38+
</thead>
39+
<tbody><tr>
40+
<td>"try hello world"</td>
41+
<td>"TrY HeLlO WoRlD"</td>
42+
</tr>
43+
</tbody>
44+
</table>
45+
<h5>입출력 예 설명</h5>
46+
47+
<p>"try hello world"는 세 단어 "try", "hello", "world"로 구성되어 있습니다. 각 단어의 짝수번째 문자를 대문자로, 홀수번째 문자를 소문자로 바꾸면 "TrY", "HeLlO", "WoRlD"입니다. 따라서 "TrY HeLlO WoRlD" 를 리턴합니다.</p>
48+
49+
<h5>문제가 잘 안풀린다면😢</h5>
50+
51+
<p>힌트가 필요한가요? [코딩테스트 연습 힌트 모음집]으로 오세요! → <a href="https://school.programmers.co.kr/learn/courses/14743?itm_content=lesson12930" target="_blank" rel="noopener">클릭</a></p>
52+
53+
54+
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function solution(s) {
2+
var answer = '';
3+
let arr = s.split(" ");
4+
for (let a of arr) {
5+
for (let i = 0; i < a.length; i++) {
6+
if (i % 2 === 0) {
7+
answer += a[i].toUpperCase();
8+
} else {
9+
answer += a[i].toLowerCase();
10+
}
11+
}
12+
answer += " ";
13+
}
14+
return answer.substring(0, answer.length - 1);
15+
}

0 commit comments

Comments
 (0)