Algorithms
Medium
2905
3170
Find Indices With Index and Value Difference II
find-indices-with-index-and-value-difference-ii
"""
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 <= 105
 * 0 <= nums[i] <= 109
 * 0 <= indexDifference <= 105
 * 0 <= valueDifference <= 109
"""
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 <= 105
 * 0 <= nums[i] <= 109
 * 0 <= indexDifference <= 105
 * 0 <= valueDifference <= 109


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": [1], "indexDifference": 0, "valueDifference": 1 }
assert my_solution.findIndices(**test_input) == [-1,-1]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [50,21,32,5], "indexDifference": 0, "valueDifference": 26 }
assert my_solution.findIndices(**test_input) == [0,1]

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

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

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

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

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

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

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

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

test_input = { "nums": [6,19,40,41,36], "indexDifference": 0, "valueDifference": 34 }
assert my_solution.findIndices(**test_input) == [0,2]

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

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

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

test_input = { "nums": [15,28,50,37,43], "indexDifference": 2, "valueDifference": 46 }
assert my_solution.findIndices(**test_input) == [-1,-1]

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

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

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

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

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

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

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

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

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

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

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

test_input = { "nums": [25,49,11,15,32,33], "indexDifference": 2, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [-1,-1]

test_input = { "nums": [0,44,42,26,15,37,23], "indexDifference": 0, "valueDifference": 17 }
assert my_solution.findIndices(**test_input) == [0,1]

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

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

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

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

test_input = { "nums": [13,3,15,48,32,19,33], "indexDifference": 1, "valueDifference": 25 }
assert my_solution.findIndices(**test_input) == [1,3]

test_input = { "nums": [29,12,42,16,50,22,10], "indexDifference": 2, "valueDifference": 29 }
assert my_solution.findIndices(**test_input) == [1,4]

test_input = { "nums": [30,48,12,15,43,17,13], "indexDifference": 3, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,3]

test_input = { "nums": [31,33,46,4,13,45,37], "indexDifference": 0, "valueDifference": 7 }
assert my_solution.findIndices(**test_input) == [0,2]

test_input = { "nums": [43,37,25,44,45,21,47], "indexDifference": 1, "valueDifference": 37 }
assert my_solution.findIndices(**test_input) == [-1,-1]

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

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

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

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

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

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

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

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