1288. Remove Covered Intervals sorted by start time x[0]. when same sorted by -x[1]. -------- end is here ------ --- --- ------- update end in this step. using a end variable to determine if the new interval is included by the previous one. if end < oneInterval[1], count ++. upadte end. class Solution(object): def removeCoveredIntervals(self, intervals): """ :type intervals: List[List[int]] :rtype: int """ if not intervals: return 0 # sort by starts and reversed end. intervals.sort(key = lambda x: (x[0], -x[1])) end = 0 count = 0 originalCount = len(intervals) for oneInterval in intervals: if oneInterval[1] > end: end = oneInterval[1] count += 1 return count