1509. Minimum Difference Between Largest and Smallest Value in Three Moves | Heap | Sorting | Greedy
Vložit
- čas přidán 1. 07. 2024
- In this video, I'll talk about how to solve Leetcode 1509. Minimum Difference Between Largest and Smallest Value in Three Moves | Sorting | Greedy
Let's Connect:
📱Discord (Join Community) : / discord
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / codewitharyanbhai
💻 Twitter - / aryan_mittal007
🤖 Github: github.com/aryan-0077
About Me:
I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
9:23 *Holiday bgm playinh*
Your Teaching Style is Awesome!!!
In love with data structures...
& appreciate your consistency of uploading daily videos.
Keep Going Bruh..
Well wishes.....
Thank you bhai!!
Great explanation!!
Thankyou bro i couldn't understand this question earlier but you really make it so simple
Thanks for providing quality content.
salute to your efforts for providing an optimised code as well...
Keep up the good work, your daily videos motivate e to do leetcode daily
best explanation so far
Thanks a lot
Your efforts sir😇
I think there is better approach without using any higher order data structure as below :
int minDifference(vector& nums) {
sort(nums.begin(),nums.end());
int n=nums.size();
int ans=INT_MAX;
if(n
its crazy i was looking for this only
wait its qs of the day
Bro, Improve the Audio quality🙂🙂
Yaa it is pretty bad this time, i'll surely correct it ❤
bhaiya please explain the binary search approach
💝💝💝💝
class Solution {
public:
int minDifference(vector& nums) {
int n = nums.size();
if(n
just want to know the difference in time and space complexity between nth element and partial_sort approach in c++ vs this approach afaik nth element in c++ uses partition method of quick sort so i think time complexity is same as this and what about space complexity
Aryan Missing Goldman sachs Tee!!😂❤
☕ Tea or Tee ?
1st Comment
❤️❤️🫡
bro can we also do the above problem in O(N) Time Complexity ?
heap approach is in O(N) time
@@6mahine_mein_google i don't think so because a single element take logN and N element will take NlogN
@@ayaaniqbal3531 here logN factor comes in because of the size of the heap but heap size is never more than 4 which means TC is Nlog4 , u can omit log4 as its a constant , thats why TC is O(N)
@@6mahine_mein_google but bro that is space complexity and I am talking about Time complexity because to get that four element we have to go to each aray element and thus NlogN
itni garmi mein ye kya phn rakah hai