1class Solution:2def intersectionSizeTwo(self, intervals: List[List[int]]) -> int:3ans = []4for x, y in sorted(intervals, key=lambda x: (x[1], -x[0])):5if not ans or ans[-2] < x:6if ans and x <= ans[-1]:7ans.append(y)8else:9ans.extend([y - 1, y])10return len(ans)