4 ms·
Since the list consists entirely of 64-bit integers, there's a trivial linear-time solution: for x in [0..2^64) count = 0 for i in [0..N) count
by bumbledraven 16y ago
Since the list consists entirely of 64-bit integers, there's a trivial linear-time solution:
for x in [0..2^64)
count = 0
for i in [0..N)
count += (array[i] == x)
}
number[count] = x // 0 <= count <= 2
}
print "missing: ", number[0]," duplicate: ", number[2]