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
| class Solution {
public String solution(String str) {
String answer="";
int cnt=0;
String[] array=str.split("");
for(int i=0; i<array.length; i++){
if(array[i].equals(" ")){
cnt=0;
answer+=" ";
}else{
cnt++;
if(cnt % 2==0){
answer+=array[i].toLowerCase();
}else{
answer+=array[i].toUpperCase();
}
}
}
return answer;
}
}
|