Skip to content

Commit b71b283

Browse files
committedJun 20, 2020
2020-06-19
1 parent e3ed08c commit b71b283

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution(object):
2+
def busyStudent(self, startTime, endTime, queryTime):
3+
"""
4+
:type startTime: List[int]
5+
:type endTime: List[int]
6+
:type queryTime: int
7+
:rtype: int
8+
"""
9+
return sum([1 for i in range(len(startTime)) if startTime[i] <= queryTime <= endTime[i]])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution(object):
2+
def arrangeWords(self, text):
3+
"""
4+
:type text: str
5+
:rtype: str
6+
"""
7+
return " ".join(sorted(text.split(), key = lambda word: len(word))).capitalize()
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution(object):
2+
def peopleIndexes(self, favoriteCompanies):
3+
"""
4+
:type favoriteCompanies: List[List[str]]
5+
:rtype: List[int]
6+
"""
7+
from collections import defaultdict
8+
9+
dic = defaultdict(set)
10+
11+
for i, l in enumerate(favoriteCompanies):
12+
for company in l:
13+
dic[company].add(i)
14+
15+
res = []
16+
for i, l in enumerate(favoriteCompanies):
17+
s = dic[l[0]]
18+
for company in l[1:]:
19+
# print i,s, dic[company]
20+
s = s & dic[company]
21+
# print s
22+
# print i, s
23+
if len(s) == 1:
24+
res.append(i)
25+
26+
return res
27+

0 commit comments

Comments
 (0)