We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Interval Selection
Interval Selection
+ 0 comments Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Interval Selection Problem Solution
+ 0 comments Here is Interval Selection problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-interval-selection-problem-solution.html
+ 0 comments I understand the question after a good 15 minutes of reading. Not Google interview worthy problem solving skills yet, but I'm proud of myself for getting this far.
+ 0 comments yes plz any one explain me problem statment
+ 1 comment 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
Load more conversations
Sort 34 Discussions, By:
Please Login in order to post a comment