Sap Labs Interview Question for Senior Software Development Engineers
- 0of 0 votes
Given the changes to SAP stock price over a period of time as an array of distinct integers, count the number of spikes in the stock price which are counted as k-Spikes.- Manoj August 27, 2023 in India
A k-Spike is an element that satisfies both the following conditions:
There are at least k elements from indices (0, -1) that are less than prices[i].
• There are at least k elements from indices (i+1, n-1) that are less than prices[i].
Count the number of k-Spikes in the given array.
prices = [1, 2, 8, 5, 3, 4] k = 2
There are 2 k-Spikes:
• 8 at index 2 has (1, 2) to the left and (5, 3, 4) to the right that are less than 8.
• 5 at index 3 has (1, 2) to the left and (3, 4) to the right that are less than 5.
Output is : 2
| Report Duplicate | Flag | PURGE
Sap Labs Senior Software Development Engineer Data Structures
Interview Type: In-Person