Skip to content

Commit 8f31bca

Browse files
authored
Add files via upload
1 parent fc711df commit 8f31bca

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from collections import defaultdict
2+
from itertools import combinations
3+
4+
def solution(orders, course):
5+
answer=[]
6+
7+
for c in course:
8+
dic=defaultdict(int)
9+
for o in orders:
10+
for com in list(combinations(sorted(o), c)):
11+
dic[com]+=1
12+
13+
if dic:
14+
m=max(dic.values())
15+
for k, v in dic.items():
16+
if v==m and v>=2:
17+
answer.append(''.join(k))
18+
19+
return sorted(answer)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
s='cdcd'
2+
3+
from collections import deque
4+
5+
stack=deque()
6+
7+
for ss in s:
8+
stack.append(ss)
9+
10+
if len(stack)>=2 and stack[-1]==stack[-2]:
11+
stack.pop()
12+
stack.pop()
13+
14+
15+
if not stack:
16+
print(1)
17+
else:
18+
print(0)

0 commit comments

Comments
 (0)