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

/**
 * Given an array full of integers, can you write a method to find the length of the longest
 * consecutive sequence inside the array?
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class FindLongestConsecutiveSequence {
  public int find(int[] array) {
    return 0;
  }
}

@@ -881,41 +881,560 @@
 e %7B%0A
-  public int find(int%5B%5D array
+%0A  /**%0A   * Iterative solution for this algorithm. This algorithm is based on a double pointer at the%0A   * start and end of the sequence and the complexity order in time terms is O(N) where N is the%0A   * number of elements in the array. In space terms, the complexity order is O(1) because we are%0A   * not using any additional data structure to keep the result.%0A   */%0A  public int find(int%5B%5D numbers) %7B%0A    if (numbers == null) %7B%0A      throw new IllegalArgumentException(%22You can't pass a null array as input.%22);%0A    %7D%0A    if (numbers.length == 0
 ) %7B%0A
+  
     
@@ -1443,14 +1443,317 @@
 turn 0;%0A
+    %7D%0A%0A    int result = 0;%0A    int start = 0, end = 0;%0A    for (int i = 1; i %3C numbers.length; i++) %7B%0A      if (numbers%5Bi - 1%5D %3C numbers%5Bi%5D) %7B%0A        end = i;%0A      %7D else %7B%0A        start = i;%0A      %7D%0A      if (end - start %3E result) %7B%0A        result = end - start;%0A      %7D%0A    %7D%0A    return result + 1;%0A
   %7D%0A%7D%0A

Add iterative solution to problem31