class Solution { public: bool validMountainArray(vector<int>& A) { int n=A.size(),x=0; for(;x<n-2&&A[x+1]>A[x];x++); if(!x) return 0; for(;x<n-1&&A[x+1]<A[x];x++); return x==n-1; } };