LeetCode solutions

3165. Find Indices With Index and Value Difference I

My accepted Python solution to LeetCode problem 3165, Find Indices With Index and Value Difference I, running in 3ms.

  • Difficulty: Easy
  • Python
  • Runtime 3ms
  • Memory 17.2MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 3ms, memory 17.2MB, accepted 2025-12-29.

python
class Solution:
    def findIndices(self, nums: List[int], indexDifference: int, valueDifference: int) -> List[int]:
        n = len(nums)
        for i in range(n):
            for j in range(n):
                if abs(i - j) >= indexDifference and abs(nums[i] - nums[j]) >= valueDifference:
                    return [i, j]
        return [-1, -1]

Source