Follow the hints! - Part 2
If you follow the hints on the problem, it really becomes super straightforward. Calculate the max chain of good indices towards the left and towards the right in two different O(N)-time loops. Iterate a third time to create the return list. Rest is history. Code is down below, cheers, ACC. Find All Good Indices - LeetCode 2420. Find All Good Indices Medium 251 19 Add to List Share You are given a 0-indexed integer array nums of size n and a positive integer k . We call an index i in the range k <= i < n - k good if the following conditions are satisfied: The k elements that are just before the index i are in non-increasing order. The k elements that are just after the index i are in non-decreasing order. Return an array of all good indices sorted in increasing order . Example 1: Input...