classSolution:defvalidMountainArray(self,arr: List[int]) ->bool: peak =0 n =len(arr)# Climb to the peak for i inrange(1, n):if arr[i]> arr[i -1]: peak = ielse:break# Climb to the peak # - peak == 0: the starting point is the peak# - peak == n - 1: the ending point is the peakif peak ==0or peak == n -1:returnFalse# Keep climbing to the endfor i inrange(peak, n -1):# if next point is larger then current point, it goes up again. if arr[i]<= arr[i +1]:returnFalsereturnTrue