Practice Minimum Absolute Difference Between Elements With Constraint
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Absolute Difference Between Elements With Constraint
Problem Statement
You are given a 0-indexed integer array nums and an integer x. Find the minimum absolute difference between two elements in the array that are at least x indices apart. In other words, find two indices i and j such that abs(i - j) >= x and abs(nums[i] - nums[j]) is minimized. Return an integer denoting the minimum absolute difference between two elements that are at least x indices apart.
Source: Minimum Absolute Difference Between Elements With Constraint on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [4,3,2,4], x = 2
0
# Example 2
nums = [5,3,2,10,15], x = 1
1
# Example 3
nums = [1,2,3,4], x = 3
3
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Absolute Difference Between Elements With Constraint.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.