Find minimum difference between any two elements | GeeksforGeeks

  Рет қаралды 28,507

GeeksforGeeks

GeeksforGeeks

8 жыл бұрын

Explanation for the article: www.geeksforgeeks.org/find-min...
This video is contributed by Harshit Jain.
Read More: www.geeksforgeeks.org/find-mi...

Пікірлер: 21
@shenth27
@shenth27 3 жыл бұрын
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.
@slimyelow
@slimyelow 3 жыл бұрын
How would I output an array with all numbers with the minimum difference.
@MOHDMUJTABA1
@MOHDMUJTABA1 5 жыл бұрын
There Could be a better solution if we are using hashmap can be done in O(n) time and O(n) space
@noorqadri3507
@noorqadri3507 4 жыл бұрын
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
@bhagyashreeswain1320
@bhagyashreeswain1320 3 жыл бұрын
Thanks a lot ..me ds abhi suru kar rahi hu mujhe isme bht dikat aarahi h but ur vdo make it simple.. ❤️
@professorsahab9210
@professorsahab9210 7 жыл бұрын
.if you already create a video on min heap or max so please send those totorial link
@professorsahab9210
@professorsahab9210 7 жыл бұрын
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?
@noorqadri3507
@noorqadri3507 4 жыл бұрын
funny how he says the simplest method and I'm still don't get it.
@professorsahab9210
@professorsahab9210 7 жыл бұрын
what is int_max?
@vishalsrivastav1964
@vishalsrivastav1964 5 жыл бұрын
Very large value equivalent to infinity
@sairajdas6692
@sairajdas6692 5 жыл бұрын
Largest value integer data type can hold
@rishabsinha8749
@rishabsinha8749 4 жыл бұрын
pow(2,31)-1 or 2 to the power 31 minus 1
@shishpal1302
@shishpal1302 5 жыл бұрын
In the brute force approach, you aren't taking adjacent pairs. it will lead to the wrong answer.
@sairajdas6692
@sairajdas6692 5 жыл бұрын
No. In brute force the array is unsorted.
@professorsahab9210
@professorsahab9210 7 жыл бұрын
plz Dear Teacher answer about this statement(int diff=INT_MAX;)
@santhoshcts5
@santhoshcts5 7 жыл бұрын
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.
@professorsahab9210
@professorsahab9210 7 жыл бұрын
butt Dear Dev compiler show an error message to write this statement what is the solution of this program
@bhargavbp3765
@bhargavbp3765 4 жыл бұрын
@@professorsahab9210 use stdlib & limits.h header file
@reyou7
@reyou7 7 жыл бұрын
@wecan2729
@wecan2729 3 жыл бұрын
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
Find duplicates in O(n) time and O(1) extra space | GeeksforGeeks
6:48
Find Maximum Difference between Two Array Elements
10:32
Programming Tutorials
Рет қаралды 23 М.
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 38 МЛН
Implement two stacks in an array | GeeksforGeeks
7:46
GeeksforGeeks
Рет қаралды 51 М.
How I'd Learn AI in 2024 (if I could start over)
17:55
Dave Ebbelaar
Рет қаралды 902 М.
First non repeating character in a stream | Leetcode #387
11:23
Maximum Length Bitonic Subarray | GeeksforGeeks
13:05
GeeksforGeeks
Рет қаралды 15 М.
Count minimum steps to get the given desired array | GeeksforGeeks
8:43
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН