Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion solution/0900-0999/0941.Valid Mountain Array/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@
<!-- 这里可写当前语言的特殊实现逻辑 -->

```python

class Solution:
def validMountainArray(self, arr: List[int]) -> bool:
n = len(arr)
if n < 3:
return False
l, r = 0, n - 1
while l + 1 < n - 1 and arr[l] < arr[l + 1]:
l += 1
while r - 1 > 0 and arr[r] < arr[r - 1]:
r -= 1
return l == r
```

### **Java**
Expand Down
12 changes: 11 additions & 1 deletion solution/0900-0999/0941.Valid Mountain Array/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@
### **Python3**

```python

class Solution:
def validMountainArray(self, arr: List[int]) -> bool:
n = len(arr)
if n < 3:
return False
l, r = 0, n - 1
while l + 1 < n - 1 and arr[l] < arr[l + 1]:
l += 1
while r - 1 > 0 and arr[r] < arr[r - 1]:
r -= 1
return l == r
```

### **Java**
Expand Down
11 changes: 11 additions & 0 deletions solution/0900-0999/0941.Valid Mountain Array/Solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
def validMountainArray(self, arr: List[int]) -> bool:
n = len(arr)
if n < 3:
return False
l, r = 0, n - 1
while l + 1 < n - 1 and arr[l] < arr[l + 1]:
l += 1
while r - 1 > 0 and arr[r] < arr[r - 1]:
r -= 1
return l == r