Explanation for the article: www.geeksforgeeks.org/find-min... This video is contributed by Harshit Jain. Read More: www.geeksforgeeks.org/find-mi...
Пікірлер: 21
@shenth273 жыл бұрын
The whole point of spending nlogn time sorting is to reduce the time complexity when doing the actual comparison, because now you only need to compare the adjacent numbers unlike the first method which compares each number with every other numbers.
@slimyelow3 жыл бұрын
How would I output an array with all numbers with the minimum difference.
@MOHDMUJTABA15 жыл бұрын
There Could be a better solution if we are using hashmap can be done in O(n) time and O(n) space
@noorqadri35074 жыл бұрын
I have to find the largest gap between two consecutive numbers in a list. (ai -- ai --i ) This is what I have so far (python) def largestGap L: maxVal = L(i): for i in range (0): L(i)=L(i) + L(i-n) if maxVal > i : maxVal == i return maxVal I don't even know if this is right, so confused, someone please help
@bhagyashreeswain13203 жыл бұрын
Thanks a lot ..me ds abhi suru kar rahi hu mujhe isme bht dikat aarahi h but ur vdo make it simple.. ❤️
@professorsahab92107 жыл бұрын
.if you already create a video on min heap or max so please send those totorial link
@professorsahab92107 жыл бұрын
your totorial is very good so dear teacher i request you to create a totorial on min heap and max heap that check the array elemnt is fulfil the condition of min heap or not?
@noorqadri35074 жыл бұрын
funny how he says the simplest method and I'm still don't get it.
@professorsahab92107 жыл бұрын
what is int_max?
@vishalsrivastav19645 жыл бұрын
Very large value equivalent to infinity
@sairajdas66925 жыл бұрын
Largest value integer data type can hold
@rishabsinha87494 жыл бұрын
pow(2,31)-1 or 2 to the power 31 minus 1
@shishpal13025 жыл бұрын
In the brute force approach, you aren't taking adjacent pairs. it will lead to the wrong answer.
@sairajdas66925 жыл бұрын
No. In brute force the array is unsorted.
@professorsahab92107 жыл бұрын
plz Dear Teacher answer about this statement(int diff=INT_MAX;)
@santhoshcts57 жыл бұрын
which means the integer.max_value in any programming language . idea is to keep it as high as possible so that when you find (arr[i+1] - arr[i] ) , for the first time will be always less than this maximum value and hence this result will be stored in diff and used for subsequent comparisons.
@professorsahab92107 жыл бұрын
butt Dear Dev compiler show an error message to write this statement what is the solution of this program
@bhargavbp37654 жыл бұрын
@@professorsahab9210 use stdlib & limits.h header file
@reyou77 жыл бұрын
@wecan27293 жыл бұрын
class Solution{ public: int minimum_difference(vectornums) { sort(nums.begin(),nums.end()); int mn=INT_MAX; int n=nums.size(); for(int i=0;i