Join Regular Classroom : Visit ClassroomTech

Coding Questions | Large Small Difference | Codewindow.in

Write a program to return the difference between the largest and smallest numbers from an array of positive integers.

Example:
Find the difference between the largest and smallest from a list of 5 numbers.

Input:
5
10 11 7 12 14

Output:
7

Example:
The first parameter (5) is the size of the array. Next is an array of integers. The difference between the largest (14) and the smallest (7) numbers is 7.

Solution:

n=int(input())
l=list(map(int,input().split()))
print(max(l)-min(l)
You Missed
Also Checkout