Algorithms
Easy
2903
3165
Find Indices With Index and Value Difference I
find-indices-with-index-and-value-difference-i
"""
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.

Your task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions:

 * abs(i - j) >= indexDifference, and
 * abs(nums[i] - nums[j]) >= valueDifference

Return an integer array answer, where answer = [i, j] if there are two such indices, and answer = [-1, -1] otherwise. If there are multiple choices for the two indices, return any of them.

Note: i and j may be equal.

Example 1:

Input: nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
Output: [0,3]
Explanation: In this example, i = 0 and j = 3 can be selected.
abs(0 - 3) >= 2 and abs(nums[0] - nums[3]) >= 4.
Hence, a valid answer is [0,3].
[3,0] is also a valid answer.

Example 2:

Input: nums = [2,1], indexDifference = 0, valueDifference = 0
Output: [0,0]
Explanation: In this example, i = 0 and j = 0 can be selected.
abs(0 - 0) >= 0 and abs(nums[0] - nums[0]) >= 0.
Hence, a valid answer is [0,0].
Other valid answers are [0,1], [1,0], and [1,1].

Example 3:

Input: nums = [1,2,3], indexDifference = 2, valueDifference = 4
Output: [-1,-1]
Explanation: In this example, it can be shown that it is impossible to find two indices that satisfy both conditions.
Hence, [-1,-1] is returned.

Constraints:

 * 1 <= n == nums.length <= 100
 * 0 <= nums[i] <= 50
 * 0 <= indexDifference <= 100
 * 0 <= valueDifference <= 50
"""
class Solution:
    def findIndices(self, nums: List[int], indexDifference: int, valueDifference: int) -> List[int]:
        
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.

Your task is to find two indices i and j, both in the range [0, n - 1], that satisfy the following conditions:

 * abs(i - j) >= indexDifference, and
 * abs(nums[i] - nums[j]) >= valueDifference

Return an integer array answer, where answer = [i, j] if there are two such indices, and answer = [-1, -1] otherwise. If there are multiple choices for the two indices, return any of them.

Note: i and j may be equal.

Example 1:

Input: nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
Output: [0,3]
Explanation: In this example, i = 0 and j = 3 can be selected.
abs(0 - 3) >= 2 and abs(nums[0] - nums[3]) >= 4.
Hence, a valid answer is [0,3].
[3,0] is also a valid answer.

Example 2:

Input: nums = [2,1], indexDifference = 0, valueDifference = 0
Output: [0,0]
Explanation: In this example, i = 0 and j = 0 can be selected.
abs(0 - 0) >= 0 and abs(nums[0] - nums[0]) >= 0.
Hence, a valid answer is [0,0].
Other valid answers are [0,1], [1,0], and [1,1].

Example 3:

Input: nums = [1,2,3], indexDifference = 2, valueDifference = 4
Output: [-1,-1]
Explanation: In this example, it can be shown that it is impossible to find two indices that satisfy both conditions.
Hence, [-1,-1] is returned.

Constraints:

 * 1 <= n == nums.length <= 100
 * 0 <= nums[i] <= 50
 * 0 <= indexDifference <= 100
 * 0 <= valueDifference <= 50


Please complete the code below to solve above prblem:
```python
class Solution:
    def findIndices(self, nums: List[int], indexDifference: int, valueDifference: int) -> List[int]:
        
```

my_solution = Solution()

test_input = { "nums": [5,1,4,1], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [2,1], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [1,2,3], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [3], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [3], "indexDifference": 1, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [4], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [7], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [8], "indexDifference": 0, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [8], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [10], "indexDifference": 0, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [11], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [18], "indexDifference": 1, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [38], "indexDifference": 1, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [40], "indexDifference": 1, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5,10], "indexDifference": 1, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [5,48], "indexDifference": 0, "valueDifference": 29 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [6,3], "indexDifference": 1, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [7,6], "indexDifference": 1, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [8,8], "indexDifference": 1, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [17,31], "indexDifference": 1, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [21,22], "indexDifference": 1, "valueDifference": 21 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [48,40], "indexDifference": 2, "valueDifference": 31 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [2,8,0], "indexDifference": 2, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [2,29,0], "indexDifference": 0, "valueDifference": 12 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [3,0,7], "indexDifference": 2, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [4,22,43], "indexDifference": 0, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [5,0,3], "indexDifference": 1, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [5,9,2], "indexDifference": 0, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [6,2,7], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [6,5,1], "indexDifference": 2, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [6,8,0], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,36,21], "indexDifference": 1, "valueDifference": 20 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [9,4,7], "indexDifference": 0, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [9,50,31], "indexDifference": 1, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [31,23,36], "indexDifference": 1, "valueDifference": 11 }
assert my_solution.findIndices(**test_input) == [1,2]

test_input = { "nums": [40,21,1], "indexDifference": 2, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [0,5,10,5], "indexDifference": 3, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [1,28,24,35], "indexDifference": 3, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [2,7,10,4], "indexDifference": 0, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [3,1,0,3], "indexDifference": 2, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,5,6,2], "indexDifference": 2, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [9,3,6,4], "indexDifference": 1, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [34,46,11,45], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [36,37,40,9], "indexDifference": 2, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [37,25,48,13], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [45,6,29,21], "indexDifference": 3, "valueDifference": 36 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [1,5,7,9,2], "indexDifference": 3, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [7,2,1,8,3], "indexDifference": 0, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [2,3]

test_input = { "nums": [8,9,8,0,4], "indexDifference": 1, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [9,1,10,0,10], "indexDifference": 0, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [9,9,4,5,5], "indexDifference": 2, "valueDifference": 9 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [10,1,10,12,1], "indexDifference": 1, "valueDifference": 3 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [17,46,31,28,28], "indexDifference": 0, "valueDifference": 46 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [17,49,1,47,12], "indexDifference": 2, "valueDifference": 17 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [32,49,3,40,44], "indexDifference": 1, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [1,2]

test_input = { "nums": [46,43,16,16,34], "indexDifference": 3, "valueDifference": 13 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [49,36,18,4,33], "indexDifference": 3, "valueDifference": 20 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [0,7,10,6,6,5], "indexDifference": 1, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [2,0,3,4,0,5], "indexDifference": 3, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [1,5]

test_input = { "nums": [3,8,9,7,2,3], "indexDifference": 3, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [3,27,38,47,38,4], "indexDifference": 0, "valueDifference": 10 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [4,13,48,50,1,26], "indexDifference": 4, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [6,1,2,6,4,6], "indexDifference": 2, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,1,0,9,5,9], "indexDifference": 2, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [7,3,7,5,7,9], "indexDifference": 1, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [12,37,7,16,5,34], "indexDifference": 3, "valueDifference": 27 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [17,46,48,25,22,4], "indexDifference": 2, "valueDifference": 30 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [18,18,7,10,9,50], "indexDifference": 2, "valueDifference": 32 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [18,42,37,13,49,42], "indexDifference": 3, "valueDifference": 46 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [23,31,14,42,0,49], "indexDifference": 4, "valueDifference": 44 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [50,46,15,16,48,7], "indexDifference": 1, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [5,6,8,5,6,3,1], "indexDifference": 0, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,6]

test_input = { "nums": [5,50,13,3,44,7,29], "indexDifference": 1, "valueDifference": 45 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [8,7,18,47,27,25,41], "indexDifference": 0, "valueDifference": 45 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [9,1,0,6,7,5,8], "indexDifference": 1, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [11,3,36,17,13,0,26], "indexDifference": 2, "valueDifference": 33 }
assert my_solution.findIndices(**test_input) == [2,5]

test_input = { "nums": [13,0,16,32,47,27,25], "indexDifference": 1, "valueDifference": 35 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [13,16,30,33,50,50,38], "indexDifference": 3, "valueDifference": 30 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [21,44,22,1,21,9,17], "indexDifference": 1, "valueDifference": 41 }
assert my_solution.findIndices(**test_input) == [1,3]

test_input = { "nums": [35,31,36,28,49,4,46], "indexDifference": 4, "valueDifference": 27 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [39,18,49,25,40,41,26], "indexDifference": 1, "valueDifference": 43 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [40,46,11,36,25,46,47], "indexDifference": 0, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [46,7,6,3,43,7,48], "indexDifference": 0, "valueDifference": 48 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,1,6,8,8,3,9,10], "indexDifference": 2, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [1,0,6,4,8,7,2,5], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [3,8,3,8,0,5,5,7], "indexDifference": 4, "valueDifference": 6 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [5,10,4,4,8,6,0,4], "indexDifference": 2, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [1,6]

test_input = { "nums": [6,1,3,7,4,4,2,1], "indexDifference": 0, "valueDifference": 5 }
assert my_solution.findIndices(**test_input) == [0,1]

test_input = { "nums": [9,36,31,2,46,1,27,37], "indexDifference": 3, "valueDifference": 45 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [10,4,0,1,4,7,2,0], "indexDifference": 5, "valueDifference": 8 }
assert my_solution.findIndices(**test_input) == [0,6]

test_input = { "nums": [26,20,19,36,20,28,33,39], "indexDifference": 0, "valueDifference": 0 }
assert my_solution.findIndices(**test_input) == [0,0]

test_input = { "nums": [29,3,30,34,25,40,10,37], "indexDifference": 5, "valueDifference": 22 }
assert my_solution.findIndices(**test_input) == [1,7]

test_input = { "nums": [39,26,46,9,5,34,0,20], "indexDifference": 0, "valueDifference": 24 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [46,12,38,21,12,9,18,29], "indexDifference": 3, "valueDifference": 35 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [1,7,7,2,4,10,1,5,9], "indexDifference": 4, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [2,4,1,5,2,0,3,5,7], "indexDifference": 5, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,5]

test_input = { "nums": [2,5,6,5,9,7,2,3,6], "indexDifference": 4, "valueDifference": 2 }
assert my_solution.findIndices(**test_input) == [0,4]

test_input = { "nums": [2,6,9,4,9,4,10,9,2], "indexDifference": 0, "valueDifference": 4 }
assert my_solution.findIndices(**test_input) == [0,1]