Array Removals
Problem Link: https://practice.geeksforgeeks.org/problems/array-removals/1
class Solution:
def removals(self,arr, n, k):
# code here
arr.sort()
j=0
ans=0
for i in range(n):
while(arr[i]-arr[j]>k):
j+=1
ans=max(ans,i-j+1)
return n-ans
PreviousMinimum Size Subarray Sum (Leetcode 209)NextLongest Substring Without Repeating Characters (Leetcode 3)
Last updated