title: Check whether exists index k such that elements of array A[] moved clockwise make a reverse bitonic array
body: <p>Check whether exists index <code>0 &lt;= k &lt; n - 2</code> such that elements of array <code>A[]</code> moved clockwise by <code>k</code> indexes make a reverse bitonic array.
  My approach to do it in <strong>O(n)</strong> time complexity:</p>
  <pre><code>bool is_antibitonicable(int A[], int n) {
      // returns if there is such index k that 
      // after moving clockwise k elements of array
      // A[], that array is reverse bitonic
      // - strictly decreasing then strictly
      // increasing
      if (n &lt; 3)
          return false;
      // if is_increasing[i] == 1 means this part of A[] is increasing,
      // == 0 means that part of A[] is decreasing, == -1 default
      int is_increasing[3] = { -1, -1, -1 };
      for (int i = 0, j; i &lt; n - 1;) {
          if (A[i] &lt; A[i + 1]) { // if A[] is increasing
              j = 0;
              while (j &lt; 3 &amp;&amp; is_increasing[j] != -1)
                  j++;
              if (j == 3)
                  return false;
              is_increasing[j] = 1;
              while (i &lt; n - 1 &amp;&amp; A[i] &lt; A[i + 1])
                  i++;
          }
          else if (A[i] &gt; A[i + 1]) { // check if decreasing
              j = 0;
              while (j &lt; 3 &amp;&amp; is_increasing[j] != -1)
                  j++;
              if (j == 3)
                  return false;
              is_increasing[j] = 0;
              while (i &lt; n - 1 &amp;&amp; A[i] &gt; A[i + 1])
                  i++;
          }
          else // sequence of A[] is neither increasing nor decreasing
              return false;
      }
      // if A[] is only increasing/decreasing
      if (is_increasing[1] == is_increasing[2])
          return false;
      // if A[] is increasing-&gt;decreasing-&gt;increasing check if increasing
      // parts can be merged into one increasing sequence
      if (is_increasing[0] == 1 &amp;&amp; is_increasing[1] == 0 &amp;&amp; is_increasing[2] == 1)
          return (A[0] &gt; A[n - 1]);
      // decreasing-&gt;increasing-&gt;decreasing
      if (is_increasing[0] == 0 &amp;&amp; is_increasing[1] == 1 &amp;&amp; is_increasing[2] == 0)
          return (A[0] &lt; A[n - 1]);
      return true; // increasing -&gt; decreasing or opposite
  }
  </code></pre>
  <p>I'd be very glad if someone could look at my solution and comment whether it seems correct or how to do it better, any feedback will be appreciated.</p>