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

/**
 * Given an input String containing a sentence, can you write a method to reverse the content of
 * the sentence without reverse every word?
 *
 * For example:
 *
 * Input: "Pedro Vicente Gómez" Output: "Gómez Vicente Pedro"
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class ReverseSentence {

}

@@ -953,10 +953,859 @@
 ence %7B%0A%0A
+  private static final String WORD_SEPARATOR = %22 %22;%0A%0A  /**%0A   * Iterative solution for this problem. The complexity order of this algorithm is equals to O(N)%0A   * where N is the number of chars in the sentence because split method is really expensive. In%0A   * space terms the complexity order is also O(N) because we are using one StringBuilder to store%0A   * the result of the algorithm.%0A   */%0A  public String reverse(String sentence) %7B%0A    if (sentence == null) %7B%0A      throw new IllegalArgumentException(%22Input param can't be null.%22);%0A    %7D%0A    StringBuilder stringBuilder = new StringBuilder();%0A    String%5B%5D words = sentence.split(WORD_SEPARATOR);%0A    for (int i = words.length - 1; i %3E= 0; i--) %7B%0A      stringBuilder.append(words%5Bi%5D);%0A      if (i != 0) %7B%0A        stringBuilder.append(%22 %22);%0A      %7D%0A    %7D%0A    return stringBuilder.toString();%0A  %7D%0A
 %7D%0A

Implement iterative solution to problem 27