Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

코딩응급실

프로그래머스: JadenCase 문자열 만들기 본문

Java

프로그래머스: JadenCase 문자열 만들기

Daeryuk Kim 2024. 3. 2. 22:37
import java.util.*;

class Solution {
    public String solution(String s) {
        String answer = "";
        String[] words = s.toLowerCase().split("");
        boolean flag = true;

        for(String str : words) {
            answer += flag ? str.toUpperCase() : str;
            flag = str.equals(" ") ? true : false; 
        }
        
        return answer;
    }
    public static void main(String[] args) {
        String s = "3people unFollowed me";

        Solution sol = new Solution();
        
        String result = sol.solution(s);
        
        System.out.println(result);
    }
}

'Java' 카테고리의 다른 글

프로그래머스: 올바른 괄호  (0) 2024.03.02
프로그래머스: 최솟값 만들기  (0) 2024.03.02
프로그래머스: 폰켓몬  (0) 2024.03.02
프로그래머스: 2016년  (0) 2024.03.02
프로그래머스: 가운데 글자 가져오기  (0) 2024.03.02