프로그래밍/HackerRank
[HackerRank][Python3] Max Min
snoopybox
2018. 7. 16. 01:00
Problem :
https://www.hackerrank.com/challenges/angry-children/problem
My Solution :
#!/usr/bin/env python3
def maxMin(k, arr):
arr.sort()
m = 10**9
for i in range(len(arr)-k+1):
m = min(m, arr[i+k-1] - arr[i])
return m
n, k = int(input()), int(input())
arr = []
for _ in range(n):
arr.append(int(input()))
result = maxMin(k, arr)
print(result)