emmm 大概是少有的连第一次测试都没有bug,并且一次提交就通过的题目了
就是代码写得比较幼稚,不够精简w(゚Д゚)w
class Solution:
def intervalIntersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
la = len(A)
lb = len(B)
ans = []
if la == 0 or lb == 0:
return ans
i = 0
j = 0
while i < la and j < lb:
ha = A[i][0]
ta = A[i][1]
hb = B[j][0]
tb = B[j][1]
x = max(ha, hb)
y = min(ta, tb)
if x <= y:
ans.append([x, y])
if y == ta:
i = i + 1
if y == tb:
j = j + 1
return ans