forked from Srinivas11789/AlgorithmNuggets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclos.py
More file actions
31 lines (24 loc) · 645 Bytes
/
clos.py
File metadata and controls
31 lines (24 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/python
import sys
def closestNumbers(arr):
arr = sorted(arr)
mini = 600000000
result = []
for i in range(len(arr)-1):
value = arr[i+1] - arr[i]
#print value
if value < mini:
mini = value
result = [arr[i], arr[i+1]]
elif value == mini:
result.append(arr[i])
result.append(arr[i+1])
else:
pass
#print mini
return result
if __name__ == "__main__":
n = int(raw_input().strip())
arr = map(int, raw_input().strip().split(' '))
result = closestNumbers(arr)
print " ".join(map(str, result))