title: Checking straight sequences in arrays
body: <p>I am trying to write a method (<code>public bool Seq_Check(int[] A, int k)</code>) that checks whether an array <code>A</code> contains numbers <code>1,2,...,k</code> (every number from <code>1</code> to <code>k</code> at least once) and no other numbers.</p>
  
  <p>So, for <code>myArr1</code> and <code>myArr2</code>, it should return <code>true</code> and <code>false</code> respectively, which it does, but wrongly shows <code>true</code> for the 3rd array.</p>
  
  <p>Can someone please help me find the bug here?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace ArrayChecker
  {
      class Program
      {
          /// The program's main entry point.
          static void Main(string[] args)
          {
              // Input arrays are assumed to be in non-decreasing order.
              int[] myArr1 = new int[] { 1, 1, 2, 3, 3 };
              int[] myArr2 = new int[] { 1, 1, 3 };
              int[] myArr3 = new int[] { 1, 1, 1, 2, 3, 4, 5, 6, 1 };
  
              // Printing to console True &amp; False respectively.
              Console.WriteLine( Seq_Check(myArr1, 3) );
              Console.WriteLine( Seq_Check(myArr2, 2) );
              Console.WriteLine( Seq_Check(myArr3, 6) );
  
              // Prevent the console window from closing.
              Console.ReadLine();
          }
  
  
          /// This method checks whether array A contains numbers 1,2,...,k
          /// (every number from 1 to k exactly once) and no other numbers.
          public static bool Seq_Check(int[] A, int k)
          {
              int n = A.Length;
  
              for (int i = 0; i &lt; n-1; i++)
              {
                  if ( A[i]+1 &lt; A[i+1] )
                      return false;
              }
  
              if ( A[0] != 1 &amp;&amp; A[n-1] != k )
                  return false;
              else
                  return true;
          }
      }
  }
  </code></pre>