/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.pedrovgs.problem52;

/**
 * Write a method to replace all spaces in a string with '%20'. You may assume that the string has
 * sufficient space at the end of the string to hold the additional characters, and that you are
 * given the "true" length of the string. (Note: if implementing in Java, please use a character
 * array so that you can perform this operation in place.)
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class ReplaceSpaces {
  public void replace(char[] input) {
    
  }
}

@@ -1081,50 +1081,1020 @@
 s %7B%0A
-  public void replace(char%5B%5D input) %7B%0A    
+%0A  /**%0A   * Iterative solution to this problem. Using two pointer we are going to iterate over the input%0A   * array using one of them and other to store the result in a temporal array. The complexity%0A   * order of this algorithm in time and space terms is O(N) where N is the number of elements in%0A   * the array.%0A   */%0A  public void replace(char%5B%5D input) %7B%0A    validateInput(input);%0A%0A    char%5B%5D result = new char%5Binput.length%5D;%0A    for (int i = 0, j = 0; i %3C input.length && j %3C input.length; i++, j++) %7B%0A      if (input%5Bi%5D == ' ') %7B%0A        result%5Bj++%5D = '%25';%0A        result%5Bj++%5D = '2';%0A        result%5Bj%5D = '0';%0A      %7D else %7B%0A        result%5Bj%5D = input%5Bi%5D;%0A      %7D%0A    %7D%0A    copyArray(result, input);%0A  %7D%0A%0A  private void copyArray(char%5B%5D src, char%5B%5D destiny) %7B%0A    for (int i = 0; i %3C src.length; i++) %7B%0A      destiny%5Bi%5D = src%5Bi%5D;%0A    %7D%0A  %7D%0A%0A  private void validateInput(char%5B%5D input) %7B%0A    if (input == null) %7B%0A      throw new IllegalArgumentException(%22You can't pass a null array as input parameter.%22);%0A    %7D
 %0A  %7D

Add iterative solution to problem 52 with O(N) as complexity order in time and space terms