본문으로 바로가기
728x90
반응형

문제

 

 

반응형

풀이

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution {
    public String solution(String s) {
        String answer = "";
        
        String[] split = s.split(" ");
        for(int i=0; i<split.length; i++) {
            if(split[i].length() == 0) {
                answer += " ";
            }else {
                answer += split[i].substring(01).toUpperCase();
                answer += split[i].substring(1split[i].length()).toLowerCase();
                answer += " ";
            }
        }
        
        if(s.substring(s.length()-1, s.length()).equals(" ")){
            return answer;
        }
        
        return answer.substring(0, answer.length()-1);
    }
}
cs

 

728x90
반응형