class Solution {
public String solution(String s) {
StringBuilder answer = new StringBuilder();
boolean firstCharFlag = true;
for (int idx = 0; idx < s.length(); idx++) {
char ch = s.charAt(idx);
if (ch != ' ' && firstCharFlag) {
answer.append(Character.toUpperCase(ch));
firstCharFlag = false;
continue;
}
answer.append(Character.toLowerCase(ch));
if (ch == ' ') firstCharFlag = true;
}
return answer.toString();
}
}