heights. You are also given a positive integer k.
The tower at index i is **prominent** if:
- at least k towers to its left are strictly lower (indices j < i with heights[j] < heights[i]);
- at least k towers to its right are strictly lower (indices j > i with heights[j] < heights[i]).
Return the number of prominent towers.heights=[1, 4, 2, 5, 3, 1], k=2 → 1
The tower of height 5 (index 3) has 1, 4 and 2 below it on the left and 3 and 1 on the right. The tower of height 4 (index 1) fails: only one lower tower stands to its left.
heights=[2, 2, 2, 2], k=1 → 0
Equal towers do not count as lower, so none qualify.
heights=[1, 3, 1, 3, 1], k=1 → 2
heights=[1, 4, 2, 5, 3, 1], k=2
1
Run checks the first 3 tests in your browser. Submit checks all 83 tests on the server, hidden ones included.