Find local minima in an array

后端 未结 7 1592
时光说笑
时光说笑 2020-12-04 09:56

Given an array of integers, find the local minima. An element A[i] is defined as a local minimum if A[i-1] > A[i] and A[i] < A[i+1] where i = 1...n-2. In case of boundar

7条回答
  •  日久生厌
    2020-12-04 10:42

    The number of local minima can be n/2; you can't enumerate them all in O(log n) time.

提交回复
热议问题