input: Write a function to optimize intervals to avoid overlaps by selecting the maximum number of non-overlapping intervals.
  assert optimize_intervals([[1,3], [2,4], [5,7], [6,8]])==[[1, 3], [5, 7]]
  assert optimize_intervals([[1,2], [3,5], [4,6], [6,8]])==[[1, 2], [3, 5], [6, 8]]
  assert optimize_intervals([[1,4], [2,3], [3,5], [7,8]])==[[1, 4], [7, 8]]
output: def optimize_intervals(intervals):
      intervals.sort(key=lambda x: x[1])
      result = []
      end_time = float('-inf')
  
      for interval in intervals:
          if interval[0] >= end_time:
              result.append(interval)
              end_time = interval[1]
  
      return result