@@ -0,0 +1,1395 @@
+package com.matao.ArraysAndStrings;%0A%0A/**%0A * Created by matao on 2018/9/30.%0A * %3Cp%3E%0A * Write a method to replace all spaces in a string with '%2520'.%0A * You may assume that the string has sufficient space at the end to hold the additional characters,%0A * and that you are given the %22true%22 length of the string.%0A * (Note: if implementing in Java, please use a character array so that you can perform this operation in place.)%0A * EXAMPLE%0A * Input: %22Mr John Smith   %22, 13%0A * Output: %22Mr%2520John%2520Smith%22%0A */%0Apublic class Q3_Urlify %7B%0A%0A    public static String replaceSpaces(char%5B%5D str, int trueLength) %7B%0A        int spaceCount = 0;%0A        for (int i = 0; i %3C trueLength; i++) %7B%0A            if (str%5Bi%5D == ' ') %7B%0A                spaceCount++;%0A            %7D%0A        %7D%0A%0A        int newLength = trueLength + 2 * spaceCount;%0A        char%5B%5D result = new char%5BnewLength%5D;%0A        int i = trueLength - 1;%0A        int j = newLength - 1;%0A        while (i %3E= 0 && j %3E= i) %7B%0A            if (str%5Bi%5D != ' ') %7B%0A                result%5Bj--%5D = str%5Bi--%5D;%0A            %7D else %7B%0A                result%5Bj--%5D = '0';%0A                result%5Bj--%5D = '2';%0A                result%5Bj--%5D = '%25';%0A                i--;%0A            %7D%0A        %7D%0A        return new String(result);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        String s = %22Mr John Smith   %22;%0A        System.out.println(replaceSpaces(s.toCharArray(), 13));%0A    %7D%0A%7D%0A

add Q3 Urlify