Minimum Number of Operations to Make Array Continuous LeetCode solution in Python
1class Solution:2def minOperations(self, nums: List[int]) -> int:3n = len(nums)4nums = sorted(set(nums))5end = 06ans = -17for i in range(len(nums)):8while end < len(nums):9if nums[i] + n > nums[end]:10end += 111else:12break13ans = max(ans, end - i)14return n - ans