L6. Job Sequencing Problem | Greedy Algorithm Playlist

Поділитися
Вставка
  • Опубліковано 25 тра 2024
  • Find problem link, notes here: takeuforward.org/strivers-a2z...
    Follow me on socials: linktr.ee/takeUforward

КОМЕНТАРІ • 30

  • @priyadarsimishra7909
    @priyadarsimishra7909 26 днів тому +15

    There is a slight error in the code. The inner for loop should start from j = deadline (arr[I].dead) till j >= 1 not 0. Because otherwise we are adding arr[0] but there is no day 0 to do work

  • @adarshmv261
    @adarshmv261 13 днів тому +5

    Day 0 or Time 0 should not be considered... As per the prob in GFG !!!

  • @samitkumar18
    @samitkumar18 Місяць тому +16

    String please 🙏

  • @siddharthchaudhary2320
    @siddharthchaudhary2320 10 днів тому +1

    Thank you striver for the yet another wonderful explanation.
    If anyone can tell how we can reduce the time complexity of internal loop to O(1) using DSU , please explain the logic. Thank you

  • @Dsa_kabaap
    @Dsa_kabaap Місяць тому +3

    Sir please start making videos on strings and stacks

  • @animexworld6614
    @animexworld6614 29 днів тому +4

    Slightly mis typed Error in code It will be hash[ j ] = arr[i].jobid ... it will be hash of j not i

  • @user-iu3yl3hp8y
    @user-iu3yl3hp8y 2 дні тому +1

    Bhaiya, Strings aur Stack and Queue ki playlist kab laoge

  • @anshulsharma3137
    @anshulsharma3137 Місяць тому +4

    Hi Striver, we can even use priority queue to optimize, basically choose only the maximum profit job from the jobs with the same deadline.

    • @dumpster-jackson
      @dumpster-jackson 23 дні тому

      That will add extra O(n) space -> priority queue. Hence sorting will be better

    • @anshulsharma3137
      @anshulsharma3137 23 дні тому +1

      @@dumpster-jackson I have given the priority queue approach to further optimize the sorting solution from O(n*n) to O(n*logn) bro. Instead of using Dsu we can use priority queue to approach

    • @dumpster-jackson
      @dumpster-jackson 19 днів тому

      @@anshulsharma3137 Good approach!!

  • @prathameshjadhav2942
    @prathameshjadhav2942 Місяць тому +1

    Understood

  • @KartikeyTT
    @KartikeyTT 8 годин тому

    tysm sir

  • @parthapratimhalder4888
    @parthapratimhalder4888 22 дні тому +2

    One thing I cannot understand why array of size 7 is taken where as max deadline is 6!!??

    • @anubhav0355
      @anubhav0355 21 день тому

      for a job with deadline 6, you will put it into hash[6] right? so size of hash must be 7 for it to have 6 as valid index!

  • @valiz2628
    @valiz2628 Місяць тому +1

  • @adarshjaiswal7334
    @adarshjaiswal7334 28 днів тому +6

    What is the concept of day0? The day should start with 1 right?

    • @divy04
      @divy04 27 днів тому

      same doubt

    • @priyadarsimishra7909
      @priyadarsimishra7909 26 днів тому +2

      I think it is to avoid like the deadline - 1 when changing value in hash, but the inner for loop should go from j = deadline to j >= 1 not till 0 because otherwise the output is not correct. I believe that is the error.

    • @nitjsrstudent5423
      @nitjsrstudent5423 24 дні тому +1

      @@priyadarsimishra7909 yeah u r correct

  • @Professor-du2pf
    @Professor-du2pf Місяць тому +1

    cout

  • @sumitmishra9795
    @sumitmishra9795 Місяць тому +1

    00:04 Solve job sequencing problem to maximize profit.
    02:15 Maximize profit by scheduling jobs with deadlines efficiently
    04:25 Maximize profit by scheduling jobs within deadlines.
    06:21 Maximizing profit by scheduling jobs based on deadlines.
    08:19 Job sequencing problem solved using Greedy Algorithm
    10:09 Understanding the comparator logic and sorting based on profit in job sequencing problem
    12:17 Iterating through jobs to maximize profit
    14:17 Optimizing job sequencing problem complexity and space

  • @Carson00_11
    @Carson00_11 Місяць тому +1

    Hello baby 🤗

  • @anuragmandal3136
    @anuragmandal3136 29 днів тому +1

    really cant understand anything he says

    • @adarshjaiswal7334
      @adarshjaiswal7334 28 днів тому +1

      You definetly will, Just don't quit for next 22 days!!