Interview Query

Minimum Absolute Distance

0
Have you seen this question before?

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 print 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), (22, 126)]
Next question: Prime Music Integration
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code