2200. Find All K-Distant Indices in an Array
Содержание
class Solution:
def findKDistantIndices(self, nums: List[int], key: int, k: int) -> List[int]:
res = []
j, n = 0, len(nums)
for i in range(n):
while j < i - k or (j < n and nums[j] != key):
j += 1
if j < n and j <= (i + k):
res.append(i)
return res