Please tell the doubt in that.
Please tell the doubt in that
A basic activity selection problem which uses Greedy approach. The implementation mentioned here states to sort the activities in the increasing order of their finishing times. Initially, we choose the first activity. Now, starting from second activity, current activity can be selected if the finish time of previous selected activity is less than or equal to the starting time of current activity.
@aryangrover i have changed your code according to above mentioned approach, please take a look and ask if anything unclear.
Thanks Sir for this.
I have one thought one more approach.
That is by hashing.
Like I can have an additional array from 1-24 and then I can take the difference of all the time periods and sort them and then I can fill the ones with minimum difference and then I can move onto the bigegr difference.
Will it be Ok?
I dont think it’ll work suppose you have more than 2 activity with same difference that overlap, how will you choose one among them?
Sir Like I have some time limits like 15-20 and also 15-16. Then first I will see the difference and then I will mark with minimum difference as 1 that is I will mark 1 at 15 and 16 also AND When We will come to check for 15-20, Then We will see if anyone from 15-20 marked as 1 then I will leave that.
Kinda that.
I think there might be some problems with this solution too.
until and unless you can prove mathematically or via induction that your algorithm is deterministic and correct, i would suggest you to just use the given greedy approach
Sir I need your help please. I am very poor in building logics just because I hadn’t purchased the basic course and is directly doing advance course. I have studied basics from Udemy but that was of no use. What can I do now? Whether I should buy Algo++ first and pause this or use that,
if arrays, string and recursion is clear than you can opt for algo++, else launchpad would be better for you.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.