pastebin

Paste Search Dynamic
Recent pastes
intervals
  1. for _ in range(int(input())):
  2.     intervals = []
  3.     n = int(input())
  4.     for _ in range(n):
  5.         intervals.append([int(val) for val in input().split()])
  6.     intervals.sort(key = lambda i : i[0])
  7.     print(intervals)
  8.     lastEnd = intervals[0][1]
  9.     remove = 0
  10.     for i in range(1, len(intervals)):
  11.         if intervals[i][0] < lastEnd:
  12.             remove += 1
  13.             lastEnd = min(lastEnd, intervals[i][1])
  14.         else:
  15.             lastEnd = intervals[i][1]
  16.     print(n-remove)
Parsed in 0.006 seconds