Reported April 2024
Amazonbinary search

Find Kth Minimum Vulnerability

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

Amazon's April OA is asking you to find the Kth minimum vulnerability, and you're probably staring at it wondering if it's a sorting problem or something sneakier. The title hints at ranking, but the real trick is recognizing that you're searching for a value, not an index. If you blank on the optimal approach during the live OA, StealthCoder will catch the binary-search pattern and guide you to the answer without the proctor seeing a thing.

Pattern and pitfall

This is a binary-search-on-answer problem. Instead of sorting and picking the Kth element directly, you search over the range of possible vulnerability values and use a helper function to count how many vulnerabilities are less than or equal to a candidate value. For each mid-point in your binary search, you check if the count meets or exceeds K. Narrow left or right based on whether you've found too few or too many. The gotcha is recognizing that you're not searching an array index; you're searching a continuous answer space. Many candidates waste time sorting when they should be binary searching the value itself. During the real OA, if you freeze on the counting logic, StealthCoder has your back with the exact pattern.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Find Kth Minimum Vulnerability 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as kth smallest element in a sorted matrix. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Kth Minimum Vulnerability FAQ

Is this just sorting and picking the Kth element?+

Not if you want the optimal solution. Sorting works for small inputs, but the problem scales better with binary search on the answer space. You're searching for a vulnerability value, not an index. The candidate function counts vulnerabilities less than or equal to a threshold.

How do I count vulnerabilities efficiently?+

You need a helper function that iterates through your vulnerability data and counts how many are less than or equal to a given value. This is called for each mid-point in your binary search. The helper is O(n), and binary search calls it O(log V) times, where V is the range of values.

What's the typical pitfall on this problem?+

Overthinking the counting logic or trying to preprocess with sorting when binary search is cleaner. Some candidates also mess up the binary search boundaries. Make sure left and right cover the full range of possible vulnerability values, not array indices.

Do I need to handle edge cases like K equals 1 or K equals N?+

Yes. K = 1 should return the minimum vulnerability. K = N should return the maximum. Your binary search bounds should handle both, but test them mentally before submitting.

How long should this take to code in an OA?+

If you recognize the binary-search-on-answer pattern, 15-20 minutes. If you're stuck on the counting or boundaries, you can burn 45 minutes. That's where having the pattern locked in beforehand saves you.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it