Find an element that occurs at least k times in a sorted array in log(n) time

前端 未结 2 1239
我寻月下人不归
我寻月下人不归 2021-01-07 11:17

Given a sorted array of n elements and a number k, is it possible to find an element that occurs more than k times, in log(n) time? If there is more than one number that occ

2条回答
  •  忘掉有多难
    2021-01-07 11:58

    Not in general. For example, if k=2, no algorithm that doesn't in the worst case inspect every element of the array can guarantee to find a duplicate.

提交回复
热议问题