Find minimum operations to make array continuous (all distinct, max-min = n-1).
Sort and deduplicate. Use sliding window to find max elements that can be kept in window [x, x+n-1].
- Sort and remove duplicates
- For each unique value as window start x: window = [x, x+n-1]
- Binary search or two-pointer to count elements in window
- Operations = n - count (replace elements outside window)
- Return minimum operations
- Time Complexity: O(n log n)
- Space Complexity: O(n)