nums
in non-decreasing order.minDifference
to a large value (e.g., Integer.MAX_VALUE
in Java or float('inf')
in Python).i
, calculate the difference between the element at index i+1
and the element at index i
.minDifference
if the current difference is smaller than the value of minDifference
.minDifference
as the result.