Count Spikes

Count Spikes is an Amazon coding interview problem. Given an array of prices and an integer k, count how many indices are k-Spikes. An index i is a k-Spike when at least k elements before i are strictly less than prices[i] and at least k elements after i are strictly less than prices[i]. Return the total count of such elements. This interview question from Amazon focuses on identifying positions that dominate enough smaller values on both sides.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: