[HackerRank][Python3] Minimum Absolute Difference in an Array
2018. 5. 29. 01:12 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/minimum-absolute-difference-in-an-array/problem
My Solution :
#!/usr/bin/env python3 def minimumAbsoluteDifference(n, arr): arr = sorted(arr) ret = arr[1] - arr[0] for i in range(1, n-1): ret = min(ret, arr[i+1] - arr[i]) return ret n = int(input()) arr = list(map(int, input().strip().split())) result = minimumAbsoluteDifference(n, arr) print(result)
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Strong Password (0) | 2018.06.05 |
---|---|
[HackerRank][Python3] Climbing the Leaderboard (0) | 2018.06.01 |
[HackerRank][Python3] The Power Sum (1) | 2018.05.31 |
[HackerRank][Python3] Construct the Array (0) | 2018.05.30 |
[HackerRank][Python3] Big Sorting (0) | 2018.05.29 |
[HackerRank][Python3] CamelCase (0) | 2018.05.27 |
[HackerRank][Python3] Journey to the Moon (0) | 2018.05.25 |
[HackerRank][Python3] Hackerland Radio Transmitters (0) | 2018.05.23 |
최근에 달린 댓글 최근에 달린 댓글