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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. Interval Selection
  5. Discussions

Interval Selection

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 34 Discussions, By:

recency

Please Login in order to post a comment

  • yashparihar729
    2 months ago+ 0 comments

    Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Interval Selection Problem Solution

    0|
    Permalink
  • thecodingsoluti2
    10 months ago+ 0 comments

    Here is Interval Selection problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-interval-selection-problem-solution.html

    -2|
    Permalink
  • HotDogTax
    2 years ago+ 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.

    -7|
    Permalink
  • manjulamitti1239
    2 years ago+ 0 comments

    yes plz any one explain me problem statment

    -1|
    Permalink
  • TChalla
    3 years ago+ 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
    
    -2|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy