Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Operations to Make Array Continuous

med
30 min
Try to solve the Minimum Number of Operations to Make Array Continuous problem.

Statement

You are given an integer array nums. In one operation, you can replace any element in nums with any other integer.

The array nums is considered continuous if both of the following conditions are satisfied:

  • All elements in nums are unique.

  • The difference between the maximum element and the minimum element in nums equals nums.length −1- 1.

Return the minimum number of operations required to make nums continuous.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Operations to Make Array Continuous

med
30 min
Try to solve the Minimum Number of Operations to Make Array Continuous problem.

Statement

You are given an integer array nums. In one operation, you can replace any element in nums with any other integer.

The array nums is considered continuous if both of the following conditions are satisfied:

  • All elements in nums are unique.

  • The difference between the maximum element and the minimum element in nums equals nums.length −1- 1.

Return the minimum number of operations required to make nums continuous.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9