Skip to content

Commit 0f54ade

Browse files
committed
[level 2] Title: JadenCase 문자열 만들기, Time: 2.74 ms, Memory: 84.7 MB -BaekjoonHub
1 parent 42023a3 commit 0f54ade

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class Solution {
2+
public String solution(String s) {
3+
String answer = "";
4+
5+
String[] words = s.split(" ");
6+
7+
for(int i=0; i<words.length; i++){
8+
if(words[i].length() == 0){
9+
answer+= " ";
10+
continue;
11+
}
12+
String word = words[i];
13+
// String first = String.valueOf(Character.toUpperCase(word.charAt(0)));
14+
answer+=word.substring(0,1).toUpperCase();
15+
// String second = "";
16+
17+
// for(int j=1; j<word.length(); j++){
18+
// second+=Character.toLowerCase(word.charAt(j));
19+
// }
20+
answer+=word.substring(1, word.length()).toLowerCase();
21+
answer+=" ";
22+
// answer+=(first+second);
23+
// if(i != words.length-1){
24+
// answer+=" ";
25+
// }
26+
}
27+
// 입력 받은 문자열의 맨 마지막이 " " 라면 바로 answer 반환
28+
if(s.substring(s.length()-1, s.length()).equals(" ")){
29+
return answer;
30+
}
31+
32+
// 맨 마지막 " " 제거하고 answer 반환
33+
return answer.substring(0, answer.length()-1);
34+
35+
// return (answer.charAt(answer.length()-1) == ' ') ? answer.substring(0, answer.length()-1) : answer;
36+
}
37+
}

프로그래머스/2/12951. JadenCase 문자열 만들기/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 10.1 MB, 시간: 0.09 ms
7+
메모리: 84.7 MB, 시간: 2.74 ms
88

99
### 구분
1010

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

1717
### 제출 일자
1818

19-
2024년 2월 1일 21:35:4
19+
2025년 05월 28일 18:55:28
2020

2121
### 문제 설명
2222

0 commit comments

Comments
 (0)