题目连接:link
这次周赛质量有点差。
1到3题,我没发现考点,就是理解题目,直接翻译成代码就可以了。而第四题,考的是计算几何,网上有类似的题目,还有源代码。
还就是下次比赛应该会用python3写了。 因为scala在做竞赛题时,会出现MLE,优化会浪费很多时间。
代码:
class Solution:
def busyStudent(self, s: List[int], e: List[int], q: int) -> int:
return sum([1 for a,b in zip(s,e) if a <= q and q <= b], 0)
class Solution:
def arrangeWords(self, text: str) -> str:
s = text.split(" ")
s[0] = s[0][0].lower() + s[0][1:]
s = sorted(s, key=lambda x: len(x))
s[0] = s[0][0].upper() + s[0][1:]
return " ".join(s)
class Solution:
def peopleIndexes(self, A: List[List[str]]) -> List[int]:
return [i for i, f in enumerate(A) if not any(set(c) > set(f) for c in A)]