Given an array of integers arr, return true if and only if it is a valid mountain array.

Recall that arr is a mountain array if and only if:


	arr.length &gt;= 3
	There exists some i with 0 &lt; i &lt; arr.length - 1 such that:
	
		arr[0] &lt; arr[1] &lt; ... &lt; arr[i - 1] &lt; arr[i] 
		arr[i] &gt; arr[i + 1] &gt; ... &gt; arr[arr.length - 1]
	
	


&nbsp;
Example 1:
Input: arr = [2,1]
Output: false
Example 2:
Input: arr = [3,5,5]
Output: false
Example 3:
Input: arr = [0,3,2,1]
Output: true

&nbsp;
Constraints:


	1 &lt;= arr.length &lt;= 104
	0 &lt;= arr[i] &lt;= 104


class Solution:
    def validMountainArray(self, arr: List[int]) -> bool:
        if len(arr) < 3:
            return False
        for i in range(1,len(arr)):
            if arr[i] <= arr[i-1]:
                if i==1:
                    return False
                break

        for j in range(i,len(arr)):
            if arr[j] >= arr[j-1]:
                return False
        return True
class Solution {
    public boolean validMountainArray(int[] arr) {
        // edge case
        if(arr.length < 3) return false;
        // keep 2 pointers
        int i=0;
        int j=arr.length-1;
        // use i pointer to iterate through steep increase from LHS
        while(i<j && arr[i]<arr[i+1]) {
            i++;
        }
        // use j pointer to iterate steep increase from RHS
        while(j>i && arr[j]<arr[j-1]) {
            j--;
        }
        // both should meet at same place and it be neither start or end.
        return i==j && i<arr.length-1 && j>0;
    }
}
class Solution {
public:
    bool validMountainArray(vector<int>& arr) {
        int flag = 1;
        if((arr.size()<=2) || (arr[1] <= arr[0])) return false;
        for(int i=1; i<arr.size(); i++){
            if(flag){
                if(arr[i] > arr[i-1]) continue;
                i--;
                flag = 0;
            }
            else{
                if(arr[i] < arr[i-1]) continue;
                return false;
            }
        }

        if(flag) return false;
        return true;
        
    }
};****
var validMountainArray = function(arr) {
  let index = 0, length = arr.length;
  //find the peak
    while(index < length && arr[index] < arr[index + 1])index++
  //edge cases
    if(index === 0 || index === length - 1) return false;
  //check if starting from peak to end of arr is descending order
    
    while(index < length && arr[index] > arr[index + 1])index++
    
    return index === length - 1;
};
Valid Mountain Array