@@ -0,0 +1,1029 @@
+public class Problem1_4 %7B%0A  public static void main(String%5B%5D args) %7B%0A    System.out.println(replaceSpaces(%22The quick brown fox       %22) + %22 should be fine%22);%0A    System.out.println(replaceSpaces(%22Thequickbrownfox       %22) + %22 should be fine%22);%0A  %7D%0A%0A  public static String replaceSpaces(String s) %7B%0A    char%5B%5D sa = s.toCharArray();%0A%0A    // find non-trailing spaces%0A    int lastNonSpace = sa.length - 1;%0A    while (sa%5BlastNonSpace%5D == ' ') %7B%0A      lastNonSpace--;%0A    %7D%0A%0A    int spaceCt = 0;%0A    for (int i = lastNonSpace; i %3E= 0; i--) %7B%0A      if (sa%5Bi%5D == ' ') spaceCt++;%0A    %7D%0A%0A    // multiply by 2 -- offset to right%0A    int offset = spaceCt * 2;%0A%0A    // iterate backwards and fill the gaps%0A    int curPos = lastNonSpace + offset;%0A    for (int i = lastNonSpace; i %3E= 0; i--) %7B%0A      if (sa%5Bi%5D != ' ') %7B%0A        sa%5BcurPos%5D = sa%5Bi%5D;%0A      %7D else %7B%0A        sa%5BcurPos%5D = '0';%0A        curPos--;%0A        sa%5BcurPos%5D = '2';%0A        curPos--;%0A        sa%5BcurPos%5D = '%25';%0A      %7D%0A      curPos--;%0A    %7D%0A%0A    return String.valueOf(sa);%0A  %7D%0A%7D%0A

Problem 1_$