title: Finding the longest contiguous subsequence in an array
body: <p>My assignment is to write a program that finds the longest increasing contiguous subsequence in a given array and prints both the length of that subsequence, and the subsequence it self.
  Say the array is: </p>
  
  <pre><code>int[] arr = {3, 6, 5, 1, 9, 3, 2, 3, 4, 5, 1}
  </code></pre>
  
  <p>The longest continuous increasing subsequence is 2, 3, 4, 5 with a length of 4. 
  So the output of this method would be</p>
  
  <pre><code>4
  2, 3, 4, 5
  </code></pre>
  
  <p>This is my code so far:</p>
  
  <pre><code>public class LongestSubsequence {
    public static void main(String[] args) {
  
      // Test arrays
      int[] arrC = {9, 5, 2, 3, 4, 5};
      int[] arrA = {1, 2, 3, 4, 5, 7};
      int[] arrB = {7, 6, 5, 4, 1, 2};
      int[] arr = {3, 6, 5, 1, 9, 3, 2, 3, 4, 5, 1};
  
      longestForward(arr);
  
    }
  
    // input of the int array, returns nothing.
    public static void longestForward(int[] arr) {
      // variables for Length of longest subsequence found and for the length of the current sequence
      int subSeqLength = 1;
      int longest = 1;
      boolean longestSub = false;
      int indexStart = 0;
      int indexEnd = 0;
  
      for (int i = 0; i &lt; arr.length-1; i++) {
        //Increases subsequence length variable 
        if (arr[i] &lt; arr[i+1]) {
          subSeqLength++;
        }
        // Sets the current subsequence to the longest variable if it is the longest one found at the time.
        else if (subSeqLength &gt; longest) {
          longest = subSeqLength;
          longestSub = true;
        }
        // if the current sequence being analyzed is the longest one, keeps track of where it starts and ends
        else if (longestSub = true) {
          arr[i] = indexStart;
          arr[i+1] = indexEnd;
        }
        // sets the subsequence length back to one if it is no longer increasing         
        else subSeqLength = 1;
      }
  
      System.out.println(subSeqLength);
      System.out.println(indexStart);
      System.out.print(indexEnd);
    }
  }
  </code></pre>
  
  <p>So I've figured out how to get the program to identify the length of the longest subsequence. However, I'm stuck on how I can actually get it to print. Right now, I'm just trying to get the method to correctly print the place in the array where the longest subsequence starts and ends. This is not what needs to be in the program, but I thought I would need to figure this out before going on to printing it.</p>
  
  <p>I reasoned that to print the subsequence, I would need to keep track of when the longest sequence started and ended, and from there get the program to print on those elemennts. But my code doesn't seem to be running correctly. There are no errors given, it just runs but doesn't return anything. </p>
  
  <p>Any help is greatly appreciated. Thanks!</p>