public class JadenCase {
public String solution(String s) {
StringBuilder sb = new StringBuilder(s.toLowerCase());
sb.replace(0, 1, (sb.charAt(0) + "").toUpperCase());
for (int i = 1; i < sb.length(); i++) {
if (sb.charAt(i) == ' ' && i < sb.length() - 1) {
sb.replace(i + 1, i + 2, (sb.charAt(i + 1) + "").toUpperCase());
}
}
return sb.toString();
}
public static void main(String[] args) {
JadenCase s = new JadenCase();
System.out.println(s.solution("3people unFollowed me"));
System.out.println(s.solution("for the last week"));
System.out.println(s.solution("hello world "));
}
}