Skip to content

Commit 16f1ee9

Browse files
committed
11/12/2020
1 parent ccde9af commit 16f1ee9

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

Daily-challenge/Dec/10/README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,21 @@ Constraints:
3333

3434
## Code
3535
```python
36-
class Solution(object):
37-
def flipAndInvertImage(self, A):
38-
result = []
39-
for row in A:
40-
result.append(list(map(lambda x: 0 if x == 1 else 1, row[::-1])))
41-
return result
36+
class Solution:
37+
def validMountainArray(self, arr: List[int]) -> bool:
38+
if len(arr) < 3:
39+
return False
40+
i = 1
41+
test = False
42+
test1 = False
43+
while i <= len(arr)-1 and arr[i] > arr[i-1]:
44+
i += 1
45+
test1 = True
46+
47+
while i <= len(arr)-1 and arr[i] < arr[i-1]:
48+
i += 1
49+
test = True
50+
return i-1 == len(arr) -1 and test and test1
51+
4252
```
4353

Daily-challenge/Dec/10/sol.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
class Solution(object):
2-
def flipAndInvertImage(self, A):
3-
result = []
4-
for row in A:
5-
result.append(list(map(lambda x: 0 if x == 1 else 1, row[::-1])))
6-
return result
1+
class Solution:
2+
def validMountainArray(self, arr: List[int]) -> bool:
3+
if len(arr) < 3:
4+
return False
5+
i = 1
6+
test = False
7+
test1 = False
8+
while i <= len(arr)-1 and arr[i] > arr[i-1]:
9+
i += 1
10+
test1 = True
11+
12+
while i <= len(arr)-1 and arr[i] < arr[i-1]:
13+
i += 1
14+
test = True
15+
return i-1 == len(arr) -1 and test and test1
16+

0 commit comments

Comments
 (0)