fork download
  1. def fn():
  2. n = 10
  3. matrix = [[5, 14], [14, 17], [8, 13], [13, 15], [15, 17], [3, 6], [4, 7], [6, 9], [11, 14], [10, 11]]
  4. print(matrix)
  5. matrix = sorted(matrix, key = lambda x: x[1])
  6. curr = matrix[0][1]
  7. count = 1
  8. for i in range(1, n):
  9. if matrix[i][0]>=curr:
  10. curr = matrix[i][1]
  11. count+=1
  12. print("Count =", count)
  13. fn()
Success #stdin #stdout 0.03s 9472KB
stdin
Standard input is empty
stdout
[[5, 14], [14, 17], [8, 13], [13, 15], [15, 17], [3, 6], [4, 7], [6, 9], [11, 14], [10, 11]]
Count = 5