Dcoder icon

The Largest Gap @ Dcoder

By Lochard | As a newbie programmer | 17 Apr 2023


Problem: Cody's teacher taught him the concept of arrays. She gave different types of homework for all the students so they won't able to copy. Cody has to find the largest gap between any two elements in the array. As Cody has a date with his girlfriend he asks your help to complete his homework.

Input: The first line of the input consists of single integer N denoting the array size.

The second line consists of N-space separated integer denoting the array elements.

 

Output: Print the largest gap present in the array.

Explanation for sample Input:

Here, we can see largest gap can be

found between 3 and 10 which is 7

Constraints: 2<=N<=10^3

.1<=Array elements<=10^4.

Sample Input: 4

3 10 6 7

Sample Output: 

7

input()
a = tuple(map(int, input().split()))
print(max(a) - min(a))

How do you rate this article?

2


Lochard
Lochard

Asylum seeker in Lithuania. My short-lifed daily on GitHub https://github.com/locharp/asylum_daily/tree/main/en


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.