There is an array of integers, his length is n. In more than half of his elements there is a constant k
that is unknown.
You can't change the array (he is read-only
) and you only have a memory of O(1)
size.
You need to find k
in best complexity (you think you can get lower than O(n)
?)
example:
{1, 6, 44, 1, 1, 8, 1} so k = 1
I thought about uding median, but I'm not allowed to change the array...
Thanks