1509. Minimum Difference Between Largest and Smallest Value in Three Moves | Heap | Sorting | Greedy

Sdílet
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

Komentáře • 29

  • @brp3522
    @brp3522 Před 21 dnem +7

    9:23 *Holiday bgm playinh*

  • @user-rk9pk9dm4z
    @user-rk9pk9dm4z Před 21 dnem +1

    Your Teaching Style is Awesome!!!
    In love with data structures...
    & appreciate your consistency of uploading daily videos.
    Keep Going Bruh..
    Well wishes.....

  • @manishprasad8736
    @manishprasad8736 Před 21 dnem

    Thank you bhai!!
    Great explanation!!

  • @varunjain3947
    @varunjain3947 Před 20 dny

    Thankyou bro i couldn't understand this question earlier but you really make it so simple

  • @sanketbhagat1222
    @sanketbhagat1222 Před 20 dny

    Thanks for providing quality content.

  • @italk-gj5kk
    @italk-gj5kk Před 20 dny

    salute to your efforts for providing an optimised code as well...

  • @cenacr007
    @cenacr007 Před 20 dny

    Keep up the good work, your daily videos motivate e to do leetcode daily

  • @kaustubhpathak5012
    @kaustubhpathak5012 Před 21 dnem

    best explanation so far

  • @hardikpatel352
    @hardikpatel352 Před 20 dny

    Thanks a lot

  • @asthajain2511
    @asthajain2511 Před 21 dnem

    Your efforts sir😇

  • @purushottamnitwarangal9263

    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

  • @user-fl5sw8op1g
    @user-fl5sw8op1g Před 21 dnem

    its crazy i was looking for this only

  • @qwerty_ra_ungamma
    @qwerty_ra_ungamma Před 21 dnem +6

    Bro, Improve the Audio quality🙂🙂

    • @ARYANMITTAL
      @ARYANMITTAL  Před 21 dnem +2

      Yaa it is pretty bad this time, i'll surely correct it ❤

  • @santhosh7042
    @santhosh7042 Před 21 dnem

    bhaiya please explain the binary search approach

  • @abytespaceneeded
    @abytespaceneeded Před 20 dny

    💝💝💝💝

  • @naveroo11
    @naveroo11 Před 9 dny

    class Solution {
    public:
    int minDifference(vector& nums) {
    int n = nums.size();
    if(n

  • @bhamidipatisatwik1165
    @bhamidipatisatwik1165 Před 19 dny

    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

  • @vickyroy3595
    @vickyroy3595 Před 21 dnem +1

    Aryan Missing Goldman sachs Tee!!😂❤

  • @AdityaDhage-1603
    @AdityaDhage-1603 Před 21 dnem +2

    1st Comment

  • @ayaaniqbal3531
    @ayaaniqbal3531 Před 21 dnem +1

    bro can we also do the above problem in O(N) Time Complexity ?

    • @6mahine_mein_google
      @6mahine_mein_google Před 21 dnem

      heap approach is in O(N) time

    • @ayaaniqbal3531
      @ayaaniqbal3531 Před 21 dnem

      @@6mahine_mein_google i don't think so because a single element take logN and N element will take NlogN

    • @6mahine_mein_google
      @6mahine_mein_google Před 21 dnem +2

      @@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)

    • @ayaaniqbal3531
      @ayaaniqbal3531 Před 21 dnem

      @@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

  • @worldofgaming748
    @worldofgaming748 Před 21 dnem +1

    itni garmi mein ye kya phn rakah hai