[프로그래머스] JadenCase 문자열 만들기(Kotlin)

0

프로그래머스

목록 보기
114/128
post-thumbnail

[프로그래머스] JadenCase 문자열 만들기(Kotlin)

풀이

class Solution {
    fun solution(s: String): String {
        var answer = ""
        
        var isStart = true
        for(ch in s){
            if(ch == ' '){
                answer += " "
                isStart = true
            }
            else{
                answer += if(isStart) ch.toUpperCase() else ch.toLowerCase()
                isStart = false
            }
        }
        return answer
    }
}
profile
Be able to be vulnerable, in search of truth

0개의 댓글