File tree Expand file tree Collapse file tree 2 files changed +32
-12
lines changed Expand file tree Collapse file tree 2 files changed +32
-12
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,21 @@ Constraints:
33
33
34
34
## Code
35
35
``` 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
+
42
52
```
43
53
Original file line number Diff line number Diff line change 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
+
You can’t perform that action at this time.
0 commit comments