Java (ArrayList)
<p>The following method should returns the length of the longest sorted sequence within a list of integers. For example, if a variable called list stores the following sequence of values: <code>{11,12,30,41,5,3,7,6}</code>, it should return <code>4</code>.</p>

<p>When the longest sorted sequence starts at front, this method fails the test(it returns <code>3</code>), but it  works for the other tests. Does anybody know where the problem is? Thank you.</p>

<pre><code>public int longestSortedSequence() {

    int count = 0;
    int max1 = 0;
                int max2 = 0;

    for (int i = 0; i &lt; size; i++) {
        if (elementData[i] &lt;= elementData[i + 1]) {
            count++;
            if (count &gt;= max1) {
                max1 = count;

            }
        } else if (elementData[i] &gt; elementData[i + 1]) {
            count = 0;
            count++;
            if (count &gt;= max2) {
                max2 = count;
            }
        }
    }
    return Math.max(max1, max2);
}
</code></pre>
