i got the concept i guess but dont know how to implement
Confused about concept
Think of a greedy approach and implement it in same pattern. Just do it as easily you can do. Sort the job according to end time. And choose the job which ends faster so that you can do another job.
Greedy-Iterative-Activity-Selector(A, s, f):
Sort A by finish times stored in
S = {A[1]}
k = 1
n = A.length
for i = 2 to n:
if s[i] ≥ f[k]:
S = S U {A[i]}
k = i
return S`
You can refer this.
get the concept of greedy approch but how to sort ,activities that is quit confusing like according to starting point or time limit
You have to sort it according to the end point of each activity.
first u need to sort the array on the basis of ending time
and then u need to calculate maximum non overlapping activities by iterating from starting index.
There must be webinar in the greedy section of your course. In that this problem is discussed. You can refer that.
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.