Find a Peak Element
Reported by candidates from Blinkit's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Blinkit OA reported in September 2026 hands you a peak element problem with one line that matters: the missing neighbor past either end counts as negative infinity. That detail is why [9,6,2] returns 0 and why a single-element array is its own peak. It's a binary search problem dressed up as an array scan, and the O(log n) requirement is the tell. If you're taking this in the next day or two, learn the one comparison that drives the search. And if you blank mid-assessment, StealthCoder runs invisibly on your screen as a safety net and gives you the solution in real time.
The problem
Given an integer array nums, return the index of its peak element. A peak is strictly greater than each neighbor that exists. For this exercise, assume a missing neighbor beyond either endpoint has value negative infinity, adjacent values are different, and the array has exactly one peak. Your algorithm should run in O(log n) time. Function findPeakElement(nums: int[]) → int Examples Example 1 nums = [1,2,3,1] return = 2 The value 3 is greater than both adjacent values. Example 2 nums = [9,6,2] return = 0 The left endpoint is greater than its only neighbor. Example 3 nums = [4] return = 0 A one-element array has a peak at index 0. Constraints 1 <= nums.length <= 10^5. -10^9 <= nums[i] <= 10^9. nums[i] != nums[i + 1] for every valid i. Exactly one index is a peak.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to compare nums[mid] with nums[mid+1]. If nums[mid] < nums[mid+1], you're on an upward slope, so a peak must exist to the right. Set lo = mid + 1. Otherwise a peak exists at mid or to its left, so set hi = mid. Loop while lo < hi and return lo. The negative infinity boundary rule guarantees the slope always ends in a peak. The common pitfall is using lo <= hi with hi = mid, which loops forever. Another is checking both neighbors and tripping over index bounds at the endpoints. Skip that, since you only ever need mid+1 and mid < hi keeps it safe. Linear scan works but fails the O(log n) requirement. If the loop condition slips your mind under pressure, StealthCoder is the hedge during the live OA. It reads the problem and hands you the clean version.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Find a Peak Element cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as find peak element. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Blinkit's OA.
Blinkit reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find a Peak Element FAQ
How hard is the Blinkit Find a Peak Element question really?+
It's easy to medium. The code is under ten lines. The difficulty is knowing that binary search works on an unsorted array, and getting the loop bounds right. If you've seen the slope-comparison idea once, it takes about five minutes to write.
What's the trick to getting O(log n)?+
Compare nums[mid] to nums[mid+1]. If the right neighbor is bigger, move lo to mid+1. If not, move hi to mid. Because the ends act as negative infinity, a peak is guaranteed in whichever half you keep.
Why not just scan the array linearly?+
A linear scan is correct but O(n), and the problem explicitly asks for O(log n). With n up to 10^5 it would likely pass small tests, but you'd miss the stated requirement. Write the binary search so you don't lose points on it.
What edge cases should I test before submitting?+
Test a single element like [4], which returns 0. Test a descending array like [9,6,2] where the peak is at index 0. Test an ascending array where the peak is the last index. These three cover the negative infinity boundary behavior.
How do I prepare for this in 48 hours?+
Write the lo < hi, hi = mid version from memory twice. Trace it by hand on [1,2,3,1] and [9,6,2]. Then do one variation where the peak sits at the far right. That's enough, since the pattern is narrow and the code is short.