title: Write a program to find length of longest consecutive sequence in array of integers?
body: <p>For example,
  Given [100, 4, 200, 1, 3, 2],
  The longest consecutive elements sequence is [1, 2, 3, 4]. </p>
  
  <pre><code> public class Array {
    public static void main(String args[]){
  
      int a[]={10,15,1,2,3,4,5,11,12};
  
      int b=1;
      int c=0;
      for(int i=0;i&lt;a.length-1;i++){
  
         if(a[i]-a[i+1]==-1){
  
           b=b+1;
           c=c+1;
           if(b&gt;=c)
         {
  
         System.out.println(a[i]);
  
           }
           else{
               b=0;
           } 
  
      }
  
  }
  }
  }
  </code></pre>
  
  <p>But i am getting output as 1 2 3 4 11
  whereas the output should be 1 2 3 4 5.</p>
  
  <p>How to get the required output,whats the mistake in a code?</p>