Practice Find All Good Indices
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
An index i is good when k <= i < nums.length - k, the k entries immediately before i are nonincreasing, and the k entries immediately after i are nondecreasing. nums[i] belongs to neither checked block. Return all good indices in increasing order.
Source: Find All Good Indices on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [2,1,1,1,3,4,1], k = 2
Output
[2,3]
# Example 2
Input
nums = [2,1,1,2], k = 2
Output
[]
Constraints
n == nums.length
3 <= n <= 10^5
1 <= nums[i] <= 10^6
1 <= k <= n / 2
Related LeetCode Problems
Practice more problems similar to Find All Good Indices.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.