Array Homework Question

前端 未结 9 1273
庸人自扰
庸人自扰 2020-12-23 16:48

You are given an array with integers between 1 and 1,000,000. One integer is in the array twice. How can you determine which one? Can you think of a way to do it using littl

9条回答
  •  不思量自难忘°
    2020-12-23 17:10

    And how about the problem of finding ALL duplicates? Can this be done in less than O(n ln n) time? (Sort & scan) (If you want to restore the original array, carry along the original index and reorder after the end, which can be done in O(n) time)

提交回复
热议问题