第二题面试角色dfs
第三题dp爬楼梯
第一题我ide上调试出来了,为什么不能在牛客上编译通过,求大佬看看。附上第一题code:
class Solution:
def merge (self, intervals, L):
intervals.sort(key= lambdax:x[0])
merged = [0]*L
for interval inintervals:
for i inrange(interval[0]- 1,interval[1]):
merged[i] +=1
return merged
# if __name__ == '__main__':
s = Solution()
T = int(input ())
L, n = map (int,input ().split())
for i in range (T):
intervals = []
for j in range(n):
x,y=map (int,input ().split())
intervals.append([x,y])
a=s.merge(intervals,L)
for num ina:
print(num ,end=' ')
全部评论
(2) 回帖