各大高校工科男身价排行# Joke - 肚皮舞运动
N*8
1 楼
给一个unsorted array,求这个数组中最小的元素差,差的定义为abs(a[i]-a[j])
where i != j .
要求O(n)时间,空间无限,数组没有上下限(既不能用radix/counting sort)。
Ex: input = {5, 13, 7, 0, 10, 20, 1, 15, 4, 18}
output = abs(0-1) = 1
有O(n)算法吗?
where i != j .
要求O(n)时间,空间无限,数组没有上下限(既不能用radix/counting sort)。
Ex: input = {5, 13, 7, 0, 10, 20, 1, 15, 4, 18}
output = abs(0-1) = 1
有O(n)算法吗?