class Solution {
public:
bool isMonotonic(vector<int>& A) {
bool increase=false;
if(A.size()==0||A.size()==1)return true;
int i;
for(i=0;i<A.size()-1;i++)
{
if(A[i]<A[i+1]){increase=true;break;}
else if(A[i]>A[i+1]){increase=false;break;}
else continue;
}
if(A[0]<A[1])increase = true;
for(i;i<A.size()-1;i++)
{
if(increase&&A[i]>A[i+1])return false;
if(!increase&&A[i]<A[i+1])return false;
}
return true;
}
};