Free written solution

Find All K-Distant Indices in an Array (LeetCode 2200): Solution and Explanation

Given an array nums, a value key and a distance k, return every index i that is at most k positions away from some index holding key, in increasing order.

Read the intuition, approach, code and complexity →