-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ1.py
More file actions
26 lines (23 loc) · 663 Bytes
/
Copy pathQ1.py
File metadata and controls
26 lines (23 loc) · 663 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Question no 1:
#Given N activities with their start and finish day given in array start[ ] and end[ ]. Select the maximum number of activities that can be performed by a single person,
#assuming that a person can only work on a single activity at a given day.
#Soliution:
#in python
def activityselection(s , f ,n):
i = 0
k=0
z=0
for j in range(n):
if(k==0):
z=z+1
k=1
else:
if s[j] >= f[i]:
i=j
z=z+1
print ("Total No of Activities that are performed")
print(z)
n=4
s = [1, 3, 2, 5]
f = [2, 4, 3, 6]
activityselection(s , f, n)