MCPcopy Create free account
hub / github.com/Rohit91singh9/Coding-DP-DSA / minimumGroups

Function minimumGroups

minimumGroups.py:1–24  ·  view source on GitHub ↗
(awards,k)

Source from the content-addressed store, hash-verified

1def minimumGroups(awards,k):
2
3 out=[]
4 awards.sort()
5 i=0
6 count=0
7 while(i<len(awards)):
8 count+=1
9 count2=0
10 temp=awards[i]
11 limit=0
12 if(temp==awards[-1]):
13 i+=1
14 for j in range(i+1,len(awards)):
15 count2+=1
16 limit=abs(temp-awards[j])
17 if(count2==len(awards)-1):
18 i+=count2+1
19
20 if(limit>k):
21 i+=count2
22 break
23
24 return count
25awards=[1,13,6,8,9,3,5] # (or) awards=[3,1,4,3,9]
26k=4 # (or) k=10
27print(minimumGroups(awards,k))

Callers 1

minimumGroups.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected