Minimum Absolute Distance
Start Timer
0:00:00
Given an array of integers, write a function min_distance
to calculate the minimum absolute distance between two elements then return all pairs having that absolute difference.
Note: Make sure to return the pairs in ascending order.
Example:
Input:
v = [3, 12, 126, 44, 52, 57, 144, 61, 68, 72, 122]
Output:
def min_distance(V) ->
min = 4
[[57, 61], [68, 72], [122, 126]]
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments