1306. Minimum Absolute Difference
My accepted Python solution to LeetCode problem 1306, Minimum Absolute Difference, running in 63ms.
- Difficulty: Easy
- Python
- Runtime 63ms
- Memory 29.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 63ms, memory 29.2MB, accepted 2025-12-30.
class Solution:
def minimumAbsDifference(self, arr: List[int]) -> List[List[int]]:
arr.sort()
min_diff = float('inf')
# Find minimum difference
for i in range(len(arr) - 1):
min_diff = min(min_diff, arr[i+1] - arr[i])
# Collect all pairs with minimum difference
result = []
for i in range(len(arr) - 1):
if arr[i+1] - arr[i] == min_diff:
result.append([arr[i], arr[i+1]])
return result