/*
 * 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.problem39;

/**
 * Given an array of elements, write a method to multiply every value for the rest of elements and
 * return a new array with this values. Can you resolve this problem without use "/" operator?
 */
public class MultiplyArrayElements {
}

@@ -883,11 +883,890 @@
 ements %7B
+%0A%0A  /**%0A   * Iterative solution to solve this problem. The complexity order of this algorithm is O(N) time%0A   * and space terms where N is the number of elements in the input array.%0A   */%0A  public int%5B%5D multiply(int%5B%5D input) %7B%0A    if (input == null) %7B%0A      throw new IllegalArgumentException(%22You can't pass a null array as input.%22);%0A    %7D%0A    if (input.length == 0) %7B%0A      return input;%0A    %7D%0A%0A    int%5B%5D front = new int%5Binput.length%5D;%0A    int%5B%5D rear = new int%5Binput.length%5D;%0A    int%5B%5D output = new int%5Binput.length%5D;%0A%0A    front%5B0%5D = 1;%0A    rear%5Binput.length - 1%5D = 1;%0A    for (int i = 1; i %3C input.length; i++) %7B%0A      front%5Bi%5D = front%5Bi - 1%5D * input%5Bi - 1%5D;%0A    %7D%0A    for (int i = input.length - 2; i %3E= 0; i--) %7B%0A      rear%5Bi%5D = rear%5Bi + 1%5D * input%5Bi + 1%5D;%0A    %7D%0A    for (int i = 0; i %3C input.length; i++) %7B%0A      output%5Bi%5D = front%5Bi%5D * rear%5Bi%5D;%0A    %7D%0A    return output;%0A  %7D
 %0A%7D%0A

Add iterative solution to problem 39