Job Sequencing Problem | Greedy Algorithms

  Рет қаралды 161,670

take U forward

take U forward

Күн бұрын

Check our Website:
In case you are thinking to buy courses, please check below:
Link to get 20% additional Discount at Coding Ninjas: bit.ly/3wE5aHx
Code "takeuforward" for 15% off at GFG: practice.geeks...
Code "takeuforward" for 20% off on sys-design: get.interviewr...?_aff=takeuforward
Crypto, I use the Wazirx app: wazirx.com/inv...
Take 750 rs free Amazon Stock from me: indmoney.oneli...
Earn 100 rs by making a Grow Account for investing: app.groww.in/v...
Linkedin/Instagram/Telegram: linktr.ee/take...
---------------------------------------------------------------------------------------------------------------------------------------------------- I have decided to make a free placement series comprising of video lectures(C++ and Java) on the entire SDE sheet.. ✅(bit.ly/takeUfo...)
✅Entire Series: bit.ly/placemen...
✅Problem link: practice.geeks...
C++/Java Code: takeuforward.o...
✅Unacademy has launched a subscription that will help you learn and interact with your favorite teacher and will also help you clear your doubts! Check it out here: unacademy.com/.... (use coupon code TAKEUFORWARD to get 10% off)
Join Unacademy's Pinnacle 2021; A Comprehensive and Concise Track to Become an Expert: unacademy.com/...
Check out Unacademy’s Free Classes and tests here (For Desktops):
www.codechef.c...
unacademy.com/...
unacademy.com/...
✅This is where I teach: ----- Use coupon-code "TAKEUFORWARD" for getting 10% on my course at GFG: bit.ly/striver_...
✅Use coupon-code "TAKEUFORWARD" for getting 10% for all GFG courses: bit.ly/tuf_gfgC...
If you appreciate the channel's work, you can join the family: bit.ly/joinFamily
Thumbnail Creator: / rikonakhuli
✅ Striver's Linkedin Profile: / rajarvp
✅ Instagram: / striver_79
Connect with us: t.me/Competiti... (Use Link in Mobile only, if not works search "takeUforward" in telegram)..
#dsa #leetcode #placements

Пікірлер: 159
@fritz6600
@fritz6600 Жыл бұрын
It's weird, I was able to get the logic once you visualized everything, I should focus on visualizing my thought process much more or elaborately I guess, thanks a lot!
@aanchalmittal9897
@aanchalmittal9897 3 жыл бұрын
You make difficult concepts look easy.... Crystal clear explanation as always ❤
@vaishnavikammara8047
@vaishnavikammara8047 11 ай бұрын
I felt so difficult to do this problem, but the way you have explained made it simple to think. 🙌
@codingwithsmallsteps2878
@codingwithsmallsteps2878 3 жыл бұрын
Nailed it striver. Thank you for the awesome explanation. The clever part is doing the job (which can be done till very late) on the last deadline unit (if the last deadline unit for the job is not occupied or just as before the last deadline unit which is not occupied) so that in the meantime you can complete the other jobs and maintaining this using a visited array.
@rahulsarkar913
@rahulsarkar913 3 жыл бұрын
Great work dada!! I found a question recently asked in amazon.. Given an integer array arr of size N and an integer S. Return the list of all pairs of elements such that for each sum of elements of each pair equals to S. Note: Each pair should be sorted i.e the first value should be less than or equals to the second value. Return the list of pairs sorted in non-decreasing order of their first value. In case if two pairs have the same first value, the pair with a smaller second value should come first. Input Format: The first line of input contains two space-separated integers N and S, denoting the size of the input array and the value of S. The second and last line of input contains N space-separated integers, denoting the elements of the input array: arr[i] where 0
@manideepaktelaprolu3073
@manideepaktelaprolu3073 3 жыл бұрын
Sort the array and apply 2 pointer technique to find the pairs.
@yatinarora1252
@yatinarora1252 3 жыл бұрын
It is similar to two sum problem
@rishabmudliar558
@rishabmudliar558 3 жыл бұрын
Instead of sorting method use a frequency array which will make the solution O(n) instead of nlogn with n space complexity
@pawankumarnandagiri8202
@pawankumarnandagiri8202 2 жыл бұрын
@@rishabmudliar558 the array elements can be negative so,so we cannot take frequency array
@VinayKumar-ze2ww
@VinayKumar-ze2ww 2 жыл бұрын
@@pawankumarnandagiri8202 unordered map is useful then Interviewer can ask for returning indices rather than values, and if we sort array, we won't find the answer
@diwakarkirar5102
@diwakarkirar5102 5 ай бұрын
After solving this question, I came here to look for the best solution and guess what it is what exactly I did, thank you so much for your videos that I am getting better everyday.
@stith_pragya
@stith_pragya 7 ай бұрын
Understood.........Thank You So Much for this wonderful video.......🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@chandanbera2692
@chandanbera2692 2 жыл бұрын
@TakeUForward As per the explanation, the result array should contain (result[j] = arr[i].id) in line 71 of java code
@sagargupta7458
@sagargupta7458 3 жыл бұрын
Please continue the playlist..
@chandan1929
@chandan1929 2 жыл бұрын
for correct job sequence put slot[j]=arr[i].id; on line 47 c++ code
@albedo9617
@albedo9617 5 ай бұрын
Is it wrong if we sort on the basis of deadline but for equal deadlines we sort on the basis of profit. That way we'll be able to finish the jobs that are expiring first but also accepting the jobs that have more profit first.
@pratikjain3323
@pratikjain3323 3 жыл бұрын
Your explanation skills are insane!! Thanks a ton. :)
@yutaitadori7318
@yutaitadori7318 3 жыл бұрын
Yes🙃
@avikmallick2493
@avikmallick2493 Жыл бұрын
instead of disjoint set u can use normal set too to it in nlogn
@jakeperalta8135
@jakeperalta8135 3 жыл бұрын
In c++ code shouldn't we store arr[i].index in slot[j] according to solution explained earlier?
@shubhamsood1406
@shubhamsood1406 3 жыл бұрын
We can do that also, we only have to change the array value from -1 to any other number, both ways of changing the array value is correct.
@manavshah7450
@manavshah7450 3 жыл бұрын
Yes. That would be better if they ask u to print the job sequence.
@mdshokeenkhan242
@mdshokeenkhan242 2 жыл бұрын
let's consider the case after sorting job id deadline profit 2 3 a[j=3] 500 4 3 a[j=2] 400 2 3 a[j=1] 300 1 3 j=3 to1 200 from here you starting the j =3 loop till 1 but in array 3,2,1 index already filled 2 5 -> 100 This is the max deadline case so in next i th iteration you filled this in array 2 1 50 but in this case profit, 200 skips and 100 is considered instead of 200 this is fine ?
@alokdwivedi2
@alokdwivedi2 2 жыл бұрын
yeah
@venkateshvenky2880
@venkateshvenky2880 2 жыл бұрын
100 is having enough time to solve later , so is included.
@ilikememes9052
@ilikememes9052 2 жыл бұрын
I can't even solve this easy question on my own. I have to watch the video for almost every single problem on SDE sheet 😔 I want to be SDE in a big tech company but now losing hope. 😢
@shadaabiqbal4875
@shadaabiqbal4875 10 ай бұрын
This is a hard level question not easy
@varunmanchanda3972
@varunmanchanda3972 3 жыл бұрын
Bhaiya, I was trying to solve it using DSU but I am not getting a correct answer. Can you please make a video on it if possible?
@_inspireverse___
@_inspireverse___ 2 жыл бұрын
Can we solve it using knapsack method if we sort by deadline in ascending order?
@mdshokeenkhan242
@mdshokeenkhan242 2 жыл бұрын
in the question's example, we are not performing the job on the deadline which is not given, and in the video answers to deadline 3 are not given but we are performing the job on day 3 ...this is something that question changes???
@ranasauravsingh
@ranasauravsingh 2 жыл бұрын
UNDERSTOOD... !!! Thanks striver for the video... :)
@mrinmoyhalder7293
@mrinmoyhalder7293 2 жыл бұрын
suppose if there are 5 jobs and all have deadline 5, and 5 is the maximum deadline among all, then for each and every deadline we've to check like this - 1+2+3+4+......(n-1) = O(n^2), isn't it
@abhijitkumarsinha
@abhijitkumarsinha 4 ай бұрын
yes, you are right !! i was thinking the same
@tusharsharma6712
@tusharsharma6712 2 жыл бұрын
I was expecting priority queue solution from you for O(NlogN) time complexity
@neerajchoudhary3709
@neerajchoudhary3709 2 жыл бұрын
usko samjh hi nahi aya hoga .lol
@devrajgoswami4357
@devrajgoswami4357 2 жыл бұрын
@@neerajchoudhary3709 you probably don't know who he's
@supriyamanna715
@supriyamanna715 2 жыл бұрын
@@devrajgoswami4357 He's what he is! Striver_79
@simitoor1
@simitoor1 2 жыл бұрын
did u get the solution in this time complexity
@supriyamanna715
@supriyamanna715 2 жыл бұрын
@@simitoor1 I think MinHeap would do that
@devanshupadhyay2658
@devanshupadhyay2658 2 жыл бұрын
best video ,related to greedy on the internet.
@Dharmik_Vibes
@Dharmik_Vibes 6 ай бұрын
way of explanation is good but code is complicate. shradha khapra code is more crisp and short .and more easy to understand but dp series is amazing
@tombrady7390
@tombrady7390 3 жыл бұрын
since we know that values will be integers can we use a stable non comparison based sorting algorithm and bring sorting complexity down to linear
@anishkumargiri9490
@anishkumargiri9490 2 жыл бұрын
I have done like this in C language - #include #include #include typedef enum{true,false}bool; typedef struct{ char id; int deed; int profit; }job; int deed(const void *p1 , const void *p2){ const job *pa=p1; const job *pb=p2; return pb->deed - pa->deed; } int compare(const void *p1 , const void *p2){ const job *pa=p1; const job *pb=p2; return pb->profit - pa->profit; } int funC(int max,bool a[]){ int i=0; if(max>1){ for(i=max-1;i>=0;i--){ if(a[i]==false){ return i+1; } } } return 0; } int main() { job arr[]={{'a',2,40},{'b',2,30},{'c',4,20},{'d',1,70}}; int size=sizeof(arr)/sizeof(arr[0]); qsort(arr,size,sizeof(arr[0]),deed); int max=arr[0].deed; qsort(arr,size,sizeof(arr[0]),compare); for(int i=0;i
@hassanmohammed904
@hassanmohammed904 2 жыл бұрын
Hey Striver, Can you upload a video on Roti-Prata Spoj problem please? Thanks in advance !!
@abhimanyu6534
@abhimanyu6534 3 жыл бұрын
Which approach does interviewer asks The one that you taught or the disjoint set approach
@ankitgarg3247
@ankitgarg3247 2 жыл бұрын
I wrote the same code.. but it is giving runtime error on GFG. Can anybody point out the mistake? class Solution { public: static bool sort_arr(Job a, Job b) { return a.profit >= b.profit; } //Function to find the maximum profit and the number of jobs done. vector JobScheduling(Job arr[], int n) { sort(arr, arr+n, sort_arr); int size = arr[0].dead; for(int i=1; i
@divyasreedev6460
@divyasreedev6460 2 жыл бұрын
For the sort_arr function, return "a.profit > b.profit" instead of "a.profit >= b.profit"
@ankitgarg3247
@ankitgarg3247 2 жыл бұрын
@@divyasreedev6460 It worked..thanks a lot :)
@divyasreedev6460
@divyasreedev6460 2 жыл бұрын
@@ankitgarg3247 You're welcome
@btRohit-st9jp
@btRohit-st9jp Жыл бұрын
@@divyasreedev6460 hey can you help me i am not getting the reason why ">=" not work if we have same profit which one come before don't matter na?
@devilcoder6432
@devilcoder6432 3 жыл бұрын
@take U forward can you please explain nlogn solution for this problem
@adityatiwari1022
@adityatiwari1022 2 жыл бұрын
can we just sort it based on deadline (primary) and then sort it based on profit(secondary) That will just require linear time after sorting
@asifd102
@asifd102 4 ай бұрын
thank you so much very good understanding
@lord_yzal
@lord_yzal 2 жыл бұрын
easy and concise explanation
@lavanya_m01
@lavanya_m01 3 жыл бұрын
GOD LEVEL EXPLANATION!!!!
@devanshmesson2777
@devanshmesson2777 3 жыл бұрын
A Big Big THANKS for your contribution♥
@gunashekarchenna3171
@gunashekarchenna3171 3 жыл бұрын
Striver, you are the saviour!!!!
@_-6912
@_-6912 3 жыл бұрын
I understood the solution and intuition!
@thelimit9719
@thelimit9719 3 жыл бұрын
if profits aare same, we should not sort deadline by ascending order?
@takeUforward
@takeUforward 3 жыл бұрын
Deadline wont matter since both of them will be having same profit and anyone after that will hace lesser profit.
@tubanishat1139
@tubanishat1139 Жыл бұрын
it took me 2 days to get a grasp on problem statement l
@jitinroy2246
@jitinroy2246 2 жыл бұрын
if(result[j]==-1){ result[j]=arr[i].id; (replacing from result[j]=i; bcz in intuition part you said to store job id) count++; jobprofit+=arr[i].profit; break; }
@adityamahimkar6138
@adityamahimkar6138 3 жыл бұрын
Bhai agar profits same ho toh phir id choose karneka kya? Just like we did in N meetings question or deadline like jiski deadline pehle voh pehle aise kuch ??
@jinhuang7258
@jinhuang7258 Жыл бұрын
Understood. Thank you!
@husler7424
@husler7424 Жыл бұрын
Where is brute force i.e. DP approach!???
@NavneetKumar-om1kc
@NavneetKumar-om1kc 2 жыл бұрын
can anyone tell what is the base of log when we are discussing time complexity?
@somyapratapsingh9849
@somyapratapsingh9849 3 жыл бұрын
The way of solving question 💯
@rudraprasaddash3809
@rudraprasaddash3809 3 жыл бұрын
Sir, how are you editing GFG default code? For me, the main function is already there and I just have to write the function only, but I want to write the code from scratch.
@ScienceSeekho
@ScienceSeekho 2 жыл бұрын
Then write in your local code editor na bhai
@lsrinivasamurthy
@lsrinivasamurthy 2 жыл бұрын
Thanks bro for the nice and clear explanation.
@sammohanty5507
@sammohanty5507 3 жыл бұрын
Hey brother All the best for the surgery.
@Saikumar-kb4lf
@Saikumar-kb4lf 3 жыл бұрын
What surgery?
@SatyaMantha
@SatyaMantha Жыл бұрын
Striver, you are awesome. Thanks a ton.
@shubhamsood1406
@shubhamsood1406 3 жыл бұрын
Time complexity is O(N^2) or O(N*logN) + O(N*M) ?
@shashikantkumar5095
@shashikantkumar5095 3 жыл бұрын
Yeah i also thing, because there is one more loop inside to find the proper index
@karthikpaladugula5424
@karthikpaladugula5424 3 жыл бұрын
N logN is for sorting N*M is identifying the slot Why N^2 term??
@akshitarora3524
@akshitarora3524 3 жыл бұрын
@@karthikpaladugula5424 if M=N-1(Worst Case) then complexity for identifying the slot will become N*(N-1) ~N^2
@omkar.gaikwad
@omkar.gaikwad 2 жыл бұрын
max value of deadline (m) is 100, hence it will not be O(n*m)
@MayankLC93
@MayankLC93 Жыл бұрын
@@omkar.gaikwad how?
@aj9706
@aj9706 3 жыл бұрын
Brilliant wat an explanation
@yashpaste7700
@yashpaste7700 3 жыл бұрын
Thank you, striver!
@bhaveshkumar6842
@bhaveshkumar6842 3 жыл бұрын
Thank you so much!!!!!!!!!!!!
@vaibhavsharma5923
@vaibhavsharma5923 9 ай бұрын
how to perform this sort?
@kenadave
@kenadave 2 жыл бұрын
Variables are "guys" 😄jokes apart, Thanks a lot for the content and really appreciate the hardwork 😇
@binodbinod7537
@binodbinod7537 3 жыл бұрын
Thank you bhaiya!!❤️✨
@pranabpaul6317
@pranabpaul6317 Жыл бұрын
Striver the comparison function need to be declared as static then it is running why so? please reply. i am also an condition if (jobCount == maxi) break; so that if jobcount is equal to maxi then no free slot is remaining so stop.
@atharvgupta4218
@atharvgupta4218 Жыл бұрын
Can someone please tell me what is wrong in this code...Only 12 cases are passed class Solution { public: static bool comparator(Job a,Job b) { return (a.profit>b.profit); } //Function to find the maximum profit and the number of jobs done. vector JobScheduling(Job arr[], int n) { int maxDeadline=arr[0].dead; sort(arr,arr+n,comparator); for(int i=1;imaxDeadline) { maxDeadline=arr[i].dead; } } vectorv(maxDeadline+1,-1);int profit=0; int c=0; for(int i=0;i0;j--) { if(v[j]==-1) { profit+=arr[i].profit; v[j]=arr[i].id; c++; break; } } } vectorans; ans.push_back(c); ans.push_back(profit); return ans; } };
@ajml_hnter
@ajml_hnter 8 ай бұрын
C++ #include using namespace std; vector jobScheduling(vector &jobs){ sort(jobs.begin(), jobs.end(), [](vector& a, const vector& b) { return a[2] > b[2]; }); int cnt = 0, profit = 0, n = jobs.size(); vector take(n+1, false); for(auto &job : jobs){ for(int i=job[1] - 1; i>=0; i--){ if(!take[i]){ take[i] = true; cnt++; profit += job[2]; break; } } } return {cnt, profit}; }
@satrap299792458
@satrap299792458 3 жыл бұрын
What if each job takes more than 1 unit of time?
@takeUforward
@takeUforward 3 жыл бұрын
Then from the back allocate that much time, simple!
@thelimit9719
@thelimit9719 3 жыл бұрын
"Each job takes 1 unit of time to complete" 0:25
@devangrajarora7002
@devangrajarora7002 3 жыл бұрын
​@@takeUforward I don't think that would work in the case where unit of time taken unit. For example, Job 1: Profit: 50, deadline: 5, time: 5 Job 2: Profit: 30, deadline: 5, time: 3 Job 3: Profit: 20, deadline: 5, time: 2 Now here we should perform Job 2 and Job 3 instead of just Job 1.
@yatinarora1252
@yatinarora1252 3 жыл бұрын
@@devangrajarora7002 I think job 1 should be done as it is having maximum profit.Simply just we will be doing job1 for continous 5 days
@manavshah7450
@manavshah7450 3 жыл бұрын
Just fill that many slots which is equal to the job time. It will work. And about your example question. Job 1 will be selected and that is correct.
@simrankureel94
@simrankureel94 3 жыл бұрын
line 36 i will start from 1
@pranjalpimpale8465
@pranjalpimpale8465 3 жыл бұрын
where can I get the code?
@yeswanthh5068
@yeswanthh5068 2 жыл бұрын
Understood sir
@RituSingh-ne1mk
@RituSingh-ne1mk 9 ай бұрын
Understood!
@lakshmiprasanna7058
@lakshmiprasanna7058 Жыл бұрын
Understood 💯💯💯
@rabatoaa857
@rabatoaa857 2 жыл бұрын
c++ 15:10
@VikasGupta-ok9lh
@VikasGupta-ok9lh Жыл бұрын
Understood
@priyanshvatsal9791
@priyanshvatsal9791 Жыл бұрын
Understood 😇
@shubhamraj5834
@shubhamraj5834 2 жыл бұрын
Thanks sir
@gautamsaxena4647
@gautamsaxena4647 6 ай бұрын
understood bhaiya
@abhishekanand9430
@abhishekanand9430 Жыл бұрын
thanks strivers
@techtoys-tx9th
@techtoys-tx9th 3 жыл бұрын
Bhaiya please consider me back to the telegram channel , I also tried to contact to u through instagram , please bhaiya consider my request and I haven't spoke anything bad and abusive and negative through out the duration for which , I was a member of that telegram channel
@takeUforward
@takeUforward 3 жыл бұрын
Telegram pe text kr do, ek hi text krna mentioning unban on telegram
@deeksha6514
@deeksha6514 3 жыл бұрын
On submitting this solution on gfg it's showing Runtime error for C++.
@takeUforward
@takeUforward 3 жыл бұрын
They have changed the problem..
@411_danishranjan9
@411_danishranjan9 2 жыл бұрын
bhai ab try kar, ab submit ho jaayega
@jitinroy2246
@jitinroy2246 2 жыл бұрын
understood
@pravinthakur7791
@pravinthakur7791 3 жыл бұрын
Needed a competitive coding partner with whom I can start my competitive coding journey .Anyone interested please reply?
@_var.onwheels
@_var.onwheels 3 жыл бұрын
Yeah bro +1
@ghoshdipan
@ghoshdipan 3 жыл бұрын
Like mind! Looking for the same.
@koushikbiswas8289
@koushikbiswas8289 3 жыл бұрын
Can I??
@cartube6219
@cartube6219 Жыл бұрын
bhaiya foreign me koi nhi dekhta hoga apki video😭😭😭plz plz hindi me samjhya kijiye. and plz code in java as well in some of your video you use only cpp and you are famous for writing code in both languages. and truly logic samajh aaya ,, lekin code nhi
@Ak-um1yg
@Ak-um1yg Жыл бұрын
code kudse kar bhai . aur kon video dekhega iska tension mat le
@jatinbhatoya8420
@jatinbhatoya8420 2 жыл бұрын
public static int[] JobScheduling(Job arr[], int n) { int ans = 0; int count = 0; int doIt[] = new int[101]; Arrays.sort(arr, (a, b) -> Integer.compare(b.profit, a.profit)); for (int i = 0; i < arr.length; i++) { int j = arr[i].deadline; while (j > 0 && doIt[j] != 0) j--; if (j > 0) { count++; ans += arr[i].profit; doIt[j] = arr[i].deadline; } } return new int[]{count, ans}; }
@pratikshadhole6694
@pratikshadhole6694 2 жыл бұрын
got it
@shashankkumar1974
@shashankkumar1974 3 жыл бұрын
hello sir can we sort the array with increasing order of deadline and if deadline is same then sort it according to max profit something like this. struct Job { int Deadline; int id; int profit; } static bool comp(Job j1,Job j2) { if(j1.deadline!=j2.deadline) return j1.profit>j2.profit; else return j1.deadline
@kartikeyaagrawal5917
@kartikeyaagrawal5917 3 жыл бұрын
it would have been right if the question said that the person doing the job cannot complete before the deadline .here in the question it is up to the person how he shedules his work. Say in ur case task 1(deadline 1day) has some profit "a" and task 2 (deadline 2) with profit "b" & task 3 with(deadline = 2) and profit c .Say here c>b>a in such a case ur program will choose task 3 and task 1 profit as a+c; but suppose he completes task 2 on day one and task 3 on day 2 he will ear b+c which is >a+c
@manavshah7450
@manavshah7450 3 жыл бұрын
Your comparator function is wrong. how can you return j1.deadline
@aj9706
@aj9706 3 жыл бұрын
Why fear when Java is here use lamda function
@nisarggogate8952
@nisarggogate8952 3 жыл бұрын
Here is a soln with sets. Making time complexity O(NlogN). The soon by TUF was of O(N^2) vector JobScheduling(Job arr[], int n) { sort(arr,arr+n,compare); set s; int ans = 0,i; for(i=1;i
@takeUforward
@takeUforward 3 жыл бұрын
S.erase takes o(n), Refer www.cplusplus.com/reference/set/set/erase/
@nisarggogate8952
@nisarggogate8952 3 жыл бұрын
@@takeUforward ohhh I didn't know... Thank you for correcting me 🙏
@arshad1679
@arshad1679 3 жыл бұрын
@@nisarggogate8952I think TUF is not correct. s.erase of a range is only O(n), else it is O(logn). Check the link.
@MrShaundan
@MrShaundan 2 жыл бұрын
@take U forward For the first version (erase(position)), amortized constant. For the second version (erase(val)), logarithmic in container size. For the last version (erase(first,last)), linear in the distance between first and last.
@RaviSingh-qd5pz
@RaviSingh-qd5pz 2 жыл бұрын
@@takeUforward I think erasing in set using an iterator take O(1) time so it has O(nlogn) time complexity.
@jitenderyadav721
@jitenderyadav721 3 жыл бұрын
Bhaiya voice phat rhi hai apki
@parikshitrathore1510
@parikshitrathore1510 3 жыл бұрын
🔥🔥
@yutaitadori7318
@yutaitadori7318 3 жыл бұрын
cool 🆒 🔥🔥🔥🔥
@saquelainmokhtar6016
@saquelainmokhtar6016 2 жыл бұрын
😍
@SANDEEPKUMAR-zo5uc
@SANDEEPKUMAR-zo5uc 3 жыл бұрын
💘
@takeUforward
@takeUforward 3 жыл бұрын
C++ Code Link: github.com/striver79/SDESheet/blob/main/jobSequencingCpp Java Code Link: github.com/striver79/SDESheet/blob/main/jobSequencingJava Live sessions on Insta: striver_79
@songs-pu9bq
@songs-pu9bq 3 жыл бұрын
🙌🙌🔥🔥
@hritikchand9930
@hritikchand9930 3 жыл бұрын
bkl ka code python mein nhi chlta
@pawanchoure1289
@pawanchoure1289 3 жыл бұрын
😁
@binodbinod7537
@binodbinod7537 3 жыл бұрын
😍😍😍
@dhruvmahalwar8642
@dhruvmahalwar8642 Жыл бұрын
what is problem with my code can someone explain vector JobScheduling(Job arr[], int n) { if(n==0) { return {0,0}; } else if(n==1) { return {1,arr[0].profit}; } int maxi=1; priority_queuepq; for(int i=0;i=1) { if(res[k]==-1||res[k]=1) { res[j-1]=res[j]; j--; } res[k]=profit; res[0]=-1; break; } k--; } } int count=0; int maxprofit=0; for(int i=1;i
@sparshtaneja
@sparshtaneja 2 жыл бұрын
shoudn't it be slot[j] = arr[i].id;
@naveensaicremsiyadlapalli3769
@naveensaicremsiyadlapalli3769 2 жыл бұрын
slot[j]=arr[i].id
@rahulgovindkumar3105
@rahulgovindkumar3105 3 жыл бұрын
Thank you bhaiya!!❤️✨
@codingp110
@codingp110 4 ай бұрын
Understood!
@NARUTOUZUMAKI-bk4nx
@NARUTOUZUMAKI-bk4nx 9 ай бұрын
Understood
@abhinanda7049
@abhinanda7049 11 ай бұрын
understood
Implement LRU Cache | Leetcode
17:05
take U forward
Рет қаралды 280 М.
L6. Job Sequencing Problem | Greedy Algorithm Playlist
16:07
take U forward
Рет қаралды 51 М.
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 166 МЛН
Симбу закрыли дома?! 🔒 #симба #симбочка #арти
00:41
Симбочка Пимпочка
Рет қаралды 4,4 МЛН
Minimum Platforms | Greedy Algorithms
18:41
take U forward
Рет қаралды 172 М.
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 163 М.
Maximum Profit in Job Scheduling - Leetcode 1235 - Python
14:45
NeetCodeIO
Рет қаралды 34 М.
The Traveling Salesman Problem: When Good Enough Beats Perfect
30:27
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 1,8 МЛН
Trapping Rainwater | Brute | Better | Optimal | with INTUITION
23:23
take U forward
Рет қаралды 279 М.
3.2 Job Sequencing with Deadlines - Greedy Method
13:29
Abdul Bari
Рет қаралды 1,4 МЛН
Greedy Algorithms Tutorial - Solve Coding Challenges
1:53:09
freeCodeCamp.org
Рет қаралды 332 М.
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 166 МЛН