Algorithm to find a duplicate entry in constant space and O(n) time

后端 未结 8 2034
我在风中等你
我在风中等你 2020-12-16 04:30

Given an array of N integer such that only one integer is repeated. Find the repeated integer in O(n) time and constant space. There is no range for the value of integers or

8条回答
  •  無奈伤痛
    2020-12-16 04:57

    As was already mentioned by others, I don't see any way to do it in O(n).

    However, you can try a probabilistic approach by using a Bloom Filter. It will give you O(n) if you are lucky.

提交回复
热议问题