2
// https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous/3
// Author: github.com/lzl124631x8
int minOperations(vector<int> &A) {9
int N = A.size(), ans = N, j = 0;10
sort(begin(A), end(A));11
A.erase(unique(begin(A), end(A)), end(A)); // only keep unique elements13
for (int i = 0; i < M; ++i) {14
while (j < M && A[j] < A[i] + N)15
++j; // let `j` point to the first element that is out of range -- `>=18
N - j + i); // The length of this subarray is `j - i`. We need to19
// replace `N - j + i` elements to make it continuous.