You are viewing a single comment's thread. Return to all comments →
My 1-line Python3 solution (passes all testcases) is similar but no abs or append.
abs
append
def minimumAbsoluteDifference(A): A.sort() ; return min( A[i+1]-A[i] for i in range(n-1) )
The native list sort is done in O(n log n) time; the naïve approach is O(n^2).
O(n log n)
O(n^2)
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Absolute Difference in an Array
You are viewing a single comment's thread. Return to all comments →
My 1-line Python3 solution (passes all testcases) is similar but no
abs
orappend
.The native list sort is done in
O(n log n)
time; the naïve approach isO(n^2)
.