2009. Minimum Number of Operations to Make Array Continuous - Day 10/31 Leetcode October Challenge

preview_player
Показать описание
Larry solves and analyzes this Leetcode problem as both an interviewer and an interviewee. This is a live recording of a real engineer solving a problem live - no cuts or edits!

#leetcode #coding #programming
Рекомендации по теме
Комментарии
Автор

Were you able to make continual improvements?

Algorithmist
Автор

your code is really clean and intuitve

adityakeshari
Автор

Great explanation as always . How did You figure out so quickly ?

DYashwanth-uj
Автор

class Solution {
public int minOperations (int []nums){
int n=nums.length, ans=n;
Arrays.sort(nums);
().ToArray();
for(int i=0;i<nums.length;++i){
int start =nums[i];
int end=start+n-1;
int idx=firstGreater (nums, end);
int len =idx-i;
ans=Math.min (ans, n-len);
}
return ans;
}
private int firstGreater (int []nums, int target){
int l=0, r=nums.length;
while(l<r){
int m=(l+r)/2;
if(nums[m]>target)
r=m;
else
l=m+1;
}
return l;
}
};
tc=nlogn;
sc=0(1);
int end=

dayashankarlakhotia
Автор

Can u please explain this in little more detail ?

rohanb
welcome to shbcf.ru