Input Array has Only One Peak


  • 1
    F

    Actually all the input arrays have only one peak. Obviously the solution won't be the same if there is an input of several peaks in an array.

    Say int[] num = {1, 2, 1, 3, 1, 4, 1}, num[i] is not equal to num[i + 1].


  • 0
    Z

    The problem actually needs more clarification on number of possible peaks. From my point of view, if an input array has a huge number of peaks (especially many are the same), it would be trivial to come up with an accurate binary search solution.


  • 0
    T

    in that case, you may return 1, 3, or, 5. anyone of them is ok. the judge system use special rules for this problem. so you do not need to worry about it.


  • 0
    F

    Yeah, I know that. That's why some clarifications on the description is needed. Otherwise It would lead us out of track. Because the input is valid.


  • 0
    F

    Yeah. The description should match better with the solution it needs.


  • 0

    Thanks. I have updated the problem statement that clarifies that the input array may contain multiple peaks. In that case return the index to any one of the peaks is fine.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.