leetcode 941. Valid Mountain Array
dont know why, but I prefer to use for instead of while.
class Solution {
public boolean validMountainArray(int[] A) {
if (A.length < 3) return false;
int i = 0;
for (; i < A.length - 1 && A[i] < A[i + 1]; ++i);
if (i == 0 || i == A.length - 1) return false;
for (; i < A.length - 1 && A[i] > A[i + 1]; ++i);
if (i != A.length - 1) return false;
return true;
}
}