Back

Circular array Difference

Created 3 years ago
120 Views
2 Comments
vishnudPuoBU
@vishnudPuoBU
vishnudPuoBU
@vishnudPuoBUProfile is locked. Login

My code:

n,m=map(int,input().split())

list=[int(item) for item in input().split()]

for i in range(0,n):

 if abs(list[i]-list[i+1])>m:

  print("1",end=" ")  

else:  

print("0",end=" ")

You are given with an circular array .Your task is calculate the difference between two consecutive number. And if difference is greater than ‘k’, print 1 else print 0

Input Description:
You are given two numbers ‘n’, ’m’. Next line contains n space separated integers.

Output Description:
Print 1 if the difference is greater than ‘m’.

Sample Input :
5 15
50 65 85 98 35
Sample Output :
0 1 0 1 0
Comments (2)
Please login to comment.