L6. Job Sequencing Problem | Greedy Algorithm Playlist

  Рет қаралды 61,737

take U forward

take U forward

Күн бұрын

Пікірлер: 82
@priyadarsimishra7909
@priyadarsimishra7909 7 ай бұрын
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
@optimus_prime01
@optimus_prime01 7 ай бұрын
ok
@rudrakshtripathi4592
@rudrakshtripathi4592 5 ай бұрын
On code360 by coding ninjas, 0 day is possible, so i thing it depends upon the question on the platform
@adityaasthana8758
@adityaasthana8758 5 ай бұрын
Absolutely true...
@vijeshsshetty
@vijeshsshetty 4 ай бұрын
beautiful
@laxitajain3811
@laxitajain3811 4 күн бұрын
yesss
@roughero1353
@roughero1353 5 ай бұрын
For the dsu approach imagine all deadlines as nodes of dsu which point to themselves. When a request for deadline comes in we fill the hash array deadline with the job id and and point the dsu deadline node to the previous day's deadline because current deadline jas become unavailable so we need the immediate previous empty deadline slot. Now if you simply do this the search will become logN so you need to do path compression so make the current requested deadline point to the ultimate parent deadline of previous day deadline. For example suppose day 3 is occupied and it points to day 2(day 2 is unoccupied as of now) and suppose request for day 4 comes in you make day 4 point to day 3 so when you next request for day 4 you can traverse back to day 2... with path compression you can directly make day 4 point to ultimate parent of day 3 which is day 2...
@MANAVSAHNI-b2v
@MANAVSAHNI-b2v 4 ай бұрын
Been looking for this everywhere... thanks a lot!
@yathartharana7956
@yathartharana7956 4 ай бұрын
Thanks :)
@vamsikrishnagannamaneni912
@vamsikrishnagannamaneni912 3 ай бұрын
great explanation
@adarshmv261
@adarshmv261 6 ай бұрын
Day 0 or Time 0 should not be considered... As per the prob in GFG !!!
@hiteshkumaryadav8373
@hiteshkumaryadav8373 24 күн бұрын
Yes. How day 0 is possible. I am stuck with this confusion.
@sumitmishra9795
@sumitmishra9795 7 ай бұрын
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
@siddharthchaudhary2320
@siddharthchaudhary2320 6 ай бұрын
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
@samitkumar18
@samitkumar18 7 ай бұрын
String please 🙏
@animexworld6614
@animexworld6614 7 ай бұрын
Slightly mis typed Error in code It will be hash[ j ] = arr[i].jobid ... it will be hash of j not i
@parthapratimhalder4888
@parthapratimhalder4888 7 ай бұрын
One thing I cannot understand why array of size 7 is taken where as max deadline is 6!!??
@anubhav0355
@anubhav0355 7 ай бұрын
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!
@Its_Shubham_Negi
@Its_Shubham_Negi 3 ай бұрын
coz with size 6, the last idx would be 5 but we wanted 6, hence hash array of size 7 is taken
@stith_pragya
@stith_pragya 5 ай бұрын
UNDERSTOOD......Thank You So Much for this wonderful video..........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@shashanksinghal8395
@shashanksinghal8395 5 ай бұрын
the question in greedy algorithm are very hard as compared to the arrays and linked lists. Does anyone else also feel that?
@DevanshMatha
@DevanshMatha 5 ай бұрын
yeah bro yesterday I encoutered a N meetings in one room problem in my OA and could't figure out the greedy approach , my brain could only think of DP.
@rajputadi01
@rajputadi01 4 ай бұрын
yesss there are so many possibilities of being greedy i cant figure out which one is correct and in the end the solution turns out to be something completely different there is a new pattern in almost every question
@NavyasriThalluri
@NavyasriThalluri 3 ай бұрын
us
@manansanghani1032
@manansanghani1032 Ай бұрын
ya even i feel that
@Dsa_kabaap
@Dsa_kabaap 7 ай бұрын
Sir please start making videos on strings and stacks
@World-Of-Mr-Motivater
@World-Of-Mr-Motivater 6 ай бұрын
striver ingeneral when speaking in an interview ,will you speak in 1.5x or 1 x speed?
@achalsayee2534
@achalsayee2534 5 ай бұрын
🤣😂
@shreyasrk6465
@shreyasrk6465 2 ай бұрын
if we consider the 0th index then it would be like having a deadline of 7 DAYS which is not true so we need to start from 1-6 that way we will be inside the deadline range👍👍
@anshulsharma3137
@anshulsharma3137 7 ай бұрын
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 7 ай бұрын
That will add extra O(n) space -> priority queue. Hence sorting will be better
@anshulsharma3137
@anshulsharma3137 7 ай бұрын
@@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 7 ай бұрын
@@anshulsharma3137 Good approach!!
@shashanksinghal8395
@shashanksinghal8395 5 ай бұрын
why are you not counting the time complexity for calculating the max_deadline by looping through the array? that will add another O(N).
@nandinii317
@nandinii317 4 ай бұрын
as that will not make any significant difference to time complexity ..as TC is already approaching to N^2
@shashanksinghal8395
@shashanksinghal8395 4 ай бұрын
@@nandinii317 yes, that's correct, but he always calculate (almost) exact time complexity of each loop and then round it off. That's why I said that. Because in my approach I have same time complexity like him but with extra O(N).
@apmotivationakashparmar722
@apmotivationakashparmar722 3 ай бұрын
Great Explaination.
@masumali8356
@masumali8356 3 ай бұрын
lovely explained...........
@kasiviswanath7981
@kasiviswanath7981 2 ай бұрын
In the if condition thee is a small error we need to update hash[j] not the hah[i]
@prankishoriitkgp3772
@prankishoriitkgp3772 3 ай бұрын
But Striver, what if all the deadlines are nth day; n=no of jobs In that case our time complexity would be O(n^2) but we are expected to solve in O(nlogn) time complexity Could you please clarify? can't we maintain a set data structure which will contain the days not occupied and according we will take the *(upper_bound(arr[i].dead)--) day
@kaichang8186
@kaichang8186 3 ай бұрын
understood, thanks for the great video
@sougatadas3760
@sougatadas3760 Ай бұрын
Chin chan chu, ching lang ding lang du
@adarshjaiswal7334
@adarshjaiswal7334 7 ай бұрын
What is the concept of day0? The day should start with 1 right?
@divy04
@divy04 7 ай бұрын
same doubt
@priyadarsimishra7909
@priyadarsimishra7909 7 ай бұрын
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 7 ай бұрын
@@priyadarsimishra7909 yeah u r correct
@EvilGod_10
@EvilGod_10 4 ай бұрын
If we have no time to perform that job, so will neglect
@UECAshutoshKumar
@UECAshutoshKumar 3 ай бұрын
Thank you
@RajGupta-i3w
@RajGupta-i3w 6 ай бұрын
Bhaiya, Strings aur Stack and Queue ki playlist kab laoge
@DeadPoolx1712
@DeadPoolx1712 2 ай бұрын
UNDERSTOOD;
@hiteshkumaryadav8373
@hiteshkumaryadav8373 24 күн бұрын
Wrong solution. Only there are 6 slots available then how can we perform 7 jobs. Day 0 doesn't exist. We can just assume that it's day 0 but its day 1. I wonder whole day frustrated about this confusion. Bro please correct this solution.
@subee128
@subee128 4 ай бұрын
Thanks
@prathameshjadhav2942
@prathameshjadhav2942 7 ай бұрын
Understood
@KartikeyTT
@KartikeyTT 6 ай бұрын
tysm sir
@valiz2628
@valiz2628 7 ай бұрын
@nassimaamohammad
@nassimaamohammad 2 ай бұрын
greedy algorithm
@Shimu-x8r
@Shimu-x8r 5 ай бұрын
can you please change the song that you have added at the end of each video.....
@Professor-du2pf
@Professor-du2pf 7 ай бұрын
cout
@viveknandan4950
@viveknandan4950 5 ай бұрын
you forget to put ;
@iamnottech8918
@iamnottech8918 5 ай бұрын
@@viveknandan4950 you forget to put------is not recoznized------compile error .
@anuragmandal3136
@anuragmandal3136 7 ай бұрын
really cant understand anything he says
@adarshjaiswal7334
@adarshjaiswal7334 7 ай бұрын
You definetly will, Just don't quit for next 22 days!!
@iamnottech8918
@iamnottech8918 5 ай бұрын
u need to stop video multiple times in between and think why he said that if video is of 16 min it means it can take atleast 1hr to understand it is normal.
@noobnessmee
@noobnessmee 4 ай бұрын
get your fundamentals right
@kushalsinha6917
@kushalsinha6917 4 ай бұрын
skill issue
@vanshikasoni6950
@vanshikasoni6950 Ай бұрын
Have you seen his previous videos? Because with background knowledge you will not be able to get it... Trust me with a sound background knowledge you can understand it all.... This guy is 10/10 on ur when it comes to DSA in C++
@Carson00_11
@Carson00_11 7 ай бұрын
Hello baby 🤗
@lofi_feels1924
@lofi_feels1924 7 ай бұрын
💀💀
@avisoft-l2p
@avisoft-l2p 2 ай бұрын
hash[j]=arr[i].profit
@KedarBhawthankar
@KedarBhawthankar 3 ай бұрын
chin tapak dam dam
@hiteshkumaryadav8373
@hiteshkumaryadav8373 24 күн бұрын
Wrong solution. Only there are 6 slots available then how can we perform 7 jobs. Day 0 doesn't exist. We can just assume that it's day 0 but its day 1. I wonder whole day frustrated about this confusion. Bro please correct this solution.
@25-cse-csmohitkumarmandal59
@25-cse-csmohitkumarmandal59 15 күн бұрын
+++ I also thought 💭 this 😂😂
@aryankumar3018
@aryankumar3018 4 ай бұрын
Understood
@akshayasuruthiark8964
@akshayasuruthiark8964 Ай бұрын
Understood
L7. N Meeting in One Room | Greedy Algorithms Playlist
13:12
take U forward
Рет қаралды 53 М.
L5. Jump Game - II | Greedy Algorithm Playlist
16:45
take U forward
Рет қаралды 78 М.
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 704 М.
3.2 Job Sequencing with Deadlines - Greedy Method
13:29
Abdul Bari
Рет қаралды 1,5 МЛН
L12. Candy | Slope Approach Intuition Based
30:10
take U forward
Рет қаралды 41 М.
L8. Trapping Rainwater | 2 Approaches | Stack and Queue Playlist
28:58
Fastest way to learn Data Structures and Algorithms
8:42
Sahil & Sarra
Рет қаралды 302 М.
L11. Valid Parenthesis String | Multiple Approaches
26:09
take U forward
Рет қаралды 54 М.
L4. Jump Game - I | Greedy Algorithm Playlist
10:53
take U forward
Рет қаралды 72 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 684 М.
L13. Fractional Knapsack Algorithm
18:41
take U forward
Рет қаралды 61 М.
Maximum Profit in Job Scheduling - Leetcode 1235 - Python
14:45
NeetCodeIO
Рет қаралды 36 М.
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.