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

后端 未结 8 2066
我在风中等你
我在风中等你 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 05:02

    Since extra space is not allowed this can't be done without comparison.The concept of lower bound on the time complexity of comparison sort can be applied here to prove that the problem in its original form can't be solved in O(n) in the worst case.

提交回复
热议问题