You are viewing a single comment's thread. Return to all comments →
Solution for my fellow Pythoners
def intervalSelection(intervals): intervals.sort(key = lambda x : x[1]) noOfSelections = 0 busy = [[0, 0], [0, 0]] for interval in intervals: if interval[0] > busy[1][1]: noOfSelections += 1 busy[1] = interval else: if interval[0] > busy[0][1]: noOfSelections += 1 busy[0] = interval if interval[1] > busy[1][1]: (busy[0], busy[1]) = (busy[1], busy[0]) return noOfSelections
Seems like cookies are disabled on this browser, please enable them to open this website
Interval Selection
You are viewing a single comment's thread. Return to all comments →
Solution for my fellow Pythoners