Practice Minimum Number of Operations to Make Array Continuous
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Hard#2009
LeetCode ProblemMinimum Number of Operations to Make Array Continuous
Problem Statement
One operation replaces any nums entry with any integer. Return the fewest replacements needed so all entries are distinct and max(nums) - min(nums) equals nums.length - 1. Their order does not have to be sorted.
Source: Minimum Number of Operations to Make Array Continuous on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [4,2,5,3]
Output
0
# Example 2
Input
nums = [1,2,3,5,6]
Output
1
# Example 3
Input
nums = [1,10,100,1000]
Output
3
Constraints
1 <= nums.length <= 10^5
1 <= nums[i] <= 10^9
Related LeetCode Problems
Practice more problems similar to Minimum Number of Operations to Make Array Continuous.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.