[Java]프로그래머스 - 이상한 문자 만들기
프로그래머스 Level 1
이상한 문자 만들기 - Java
class Solution {
public String solution(String s) {
String answer = "";
int index = 0;
String[] arr = s.split("");
for(String str : arr) {
index = str.contains(" ") ? 0 : index+1;
answer += index % 2 == 0 ? str.toLowerCase() : str.toUpperCase();
}
return answer;
}
}
Leave a comment