One good insight for similar questions: If the array is sorted, you can find a way to skip elements -> using binary search.
This is similar to the question-> Find peak element in a sorted array -> use Binary search again to find middle element and check middle-1 and middle+1 for peak invariant.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
One good insight for similar questions: If the array is sorted, you can find a way to skip elements -> using binary search.
This is similar to the question-> Find peak element in a sorted array -> use Binary search again to find middle element and check middle-1 and middle+1 for peak invariant.