Skip to content

Commit c3e9e67

Browse files
Merge pull request keshavsingh4522#133 from keshavsingh4522/keshav
Keshav
2 parents d9b90cf + 9885240 commit c3e9e67

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#https://leetcode.com/explore/challenge/card/december-leetcoding-challenge/570/week-2-december-8th-december-14th/3562/
2+
class Solution:
3+
def removeDuplicates(self, a: List[int]) -> int:
4+
d=dict()
5+
c=0
6+
for i in range(len(a)):
7+
try:
8+
d[a[i-c]]+=1
9+
if d[a[i-c]]>2:
10+
a.pop(i-c)
11+
c+=1
12+
except:
13+
d[a[i-c]]=1
14+
return len(a)

Diff for: LeetCode/December 2020/Valid Mountain Array.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#https://leetcode.com/explore/challenge/card/december-leetcoding-challenge/570/week-2-december-8th-december-14th/3561/
2+
class Solution:
3+
def validMountainArray(self, a: List[int]) -> bool:
4+
if len(a)<3:
5+
return False
6+
if a[0]>a[1]:
7+
return False
8+
9+
d=0
10+
i=0
11+
k=0
12+
for j in range(len(a)-1):
13+
if a[j+1]>a[j]:
14+
if i==0:
15+
i=1
16+
k+=1
17+
d=0
18+
elif a[j+1]<a[j]:
19+
if d==0:
20+
k+=1
21+
d=1
22+
i=0
23+
else:
24+
return False
25+
if k>2:
26+
return False
27+
if k==2:
28+
return True
29+
return False

0 commit comments

Comments
 (0)