Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,951 views
in Online Assessments by Expert (46,090 points) | 1,951 views

2 Answers

0 like 0 dislike
def min_groups(n,arr,k) :
    arr.sort()

    count=1
    min_value = arr[0]
    i=1
    while i<len(arr):
        if arr[i] > min_value + k :
            count+=1
            min_value=arr[i]
        i+=1
    return count

n=int(input())
arr=[]
for i in range(n):
    arr.append(int(input()))
k=int(input())
print(min_groups(n,arr,k))
by (140 points)
0 like 0 dislike

IMAGES OF QUES

imageimage

imageimage

 

by Expert (46,090 points)