Sliding Window Maximum | Sliding Window Algorithm | Deque Data Structure | DSA-One Course #54

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • Hey guys, In this video, We're going to solve another very famous Interview Problem called - Sliding Window Maximum
    0:00 Problem statement
    1:41 Naive Solution
    2:31 Naive Solution code
    3:26 Using AVL tree/Max Heap
    6:51 Using Max heap code
    8:23 Using Deque
    15:06 Using Deque code
    code: www.geeksforgeeks.org/sliding...
    🥳 Join our Telegram Community:
    Telegram channel: telegram.me/realanujbhaiya
    Telegram group: telegram.me/dsa_one
    🚀 Follow me on:
    Instagram: / anuj.kumar.sharma
    Linkedin: / sharma-kumar-anuj
    Twitter: / realanujbhaiya
    💸 Use coupon code ANUJBHAIYA on GeeksforGeeks to avail discounts on courses!
    📚 Complete DSA Playlist: • DSA-One Course - The C...
    Complete Android Development Playlist: • Android Development Tu...
    Hashtags:
    #anujbhaiya #dsaone
    Tags:
    sliding window maximum
    sliding window algorithm
    sliding window
    maximum of all subarrays of size k
    sliding window problem
    sliding window technique algorithm
    anuj bhaiya
    sliding window technique
    sliding window java
    239. sliding window maximum
    sliding window dsa
    sliding window c++
    maximum of minimum for every window size
    first negative integer in every window of size k
    sliding window playlist
    deque
    sliding window maximum leetcode
    sliding windows
    sliding window problems
    window sliding technique
    maximum sliding window
    sliding window max
    sliding window python
    sliding window in java
    window sliding
    dequeue in data structure
    find the maximum of minimums of every window size
    leetcode 239
    deque data structure
    dsa
    monotonic queue
    sliding window concept
    sliding window leetcode
    anuj bhaiya dsa
    anuj bhaiya java
    sliding window approach
    sliding window maximum (maximum of all subarrays of size k)
    sliding window median
    java+dsa
    sliding window coding
    sliding window javascript
    sliding window protocol
    smallest distinct window
    apna college
    dequeue in java
    double ended queue
    dsa one
    maximum erasure value
    maximum subarray problem
    maximum sum subarray of size k
    minimize the maximum difference between the heights
    sidemen spend
    sliding
    sliding window code
    sliding window pattern
    sliding window questions

Komentáře • 90

  • @arifsaleem-7377
    @arifsaleem-7377 Před 4 měsíci +1

    i never go without liking your video. i don't know why people even can't do this for you when they take huge knowledge for free. people should respect the effort.
    i also try to let run ads completely whenever i can so that you can get some benefit. this is the least that we can do while watching your videos...

  • @shristiiverma1106
    @shristiiverma1106 Před 2 lety +20

    Congratulations bhaiya for 200k family.🥳🎉🎉🎉🎉🎉🎉🎉❣️ waiting for 1 million 🥺

  • @preetkatiyar969
    @preetkatiyar969 Před 2 lety

    I always takes very deep interest in your videos because your explanation is very simple for understanding sir ❤️❤️

  • @sakshichauhan5534
    @sakshichauhan5534 Před 5 měsíci

    Best way of explaining DSA question. your videos are amazing

  • @rahul-sinha
    @rahul-sinha Před 2 lety +7

    I have seen many youtuber teachers , but this way of explaination and sense of logic satisfation only coming with ANUJ BHAIYA..
    Thanks A LOT.....

    • @AmanKumarSINGH-dj5sk
      @AmanKumarSINGH-dj5sk Před rokem +2

      q jhooth bol rha hai bhai

    • @rahul-sinha
      @rahul-sinha Před rokem +1

      @@AmanKumarSINGH-dj5sk Bro, I find his way of explaination very helpful, because his explanation is very simple for understanding, in my case.
      You might need to explore more !

  • @AnishKumarSingh-su1dg
    @AnishKumarSingh-su1dg Před 2 lety

    Crystal Clear Explaination

  • @King_21-d2t
    @King_21-d2t Před 2 lety +2

    Bhaiya Thanks for this course!

  • @MsVaibhav14
    @MsVaibhav14 Před 2 lety +3

    Bhai ye to interview material hai ... Coding Ninja k paise bacch gaye. Grateful for the work you are putting out there.

  • @user-iq8pu4xq9o
    @user-iq8pu4xq9o Před 10 měsíci

    Pure Nice explanation....

  • @RobinSingh-ms3zt
    @RobinSingh-ms3zt Před rokem

    Thanks bro awesome explanation.

  • @madhavdua8588
    @madhavdua8588 Před rokem +2

    Its very important problem . It is used in another Q as a part. Try to memorize and practice O(n) approach.

  • @amitbhagat5349
    @amitbhagat5349 Před 2 lety +1

    Great Tutorial Bhaiya

  • @ismailhossain4730
    @ismailhossain4730 Před 2 lety +1

    Congrats for 200k, love from🇧🇩

  • @patelmujib7087
    @patelmujib7087 Před 2 lety +1

    many many congratulation anuj sir

  • @parthap3
    @parthap3 Před 2 lety +7

    Congrats Anuj Bhaiya for 200k subscribers 🎊🎊. And Thank you I have recently secured a job with the help of your Java course at Apni kaksha and DSA One Course 🙏❤️❤️

  • @govindsharma7696
    @govindsharma7696 Před 2 lety +1

    Congratulations bhaiya for 200k 🎉🎉

  • @vedantbhardwaj882
    @vedantbhardwaj882 Před rokem +1

    This video helped a lot

  • @vinaybadola4681
    @vinaybadola4681 Před 2 lety +8

    Congratulations bhaiya 200k more to go 😁 btw bhut helpful video ❤❤

  • @akashsaggu728
    @akashsaggu728 Před 2 lety +1

    Thank you 😌

  • @vaarigupta6332
    @vaarigupta6332 Před rokem

    Nice Explanation Sir

  • @chandanpandey1847
    @chandanpandey1847 Před 2 lety

    Useful ❤️🙏

  • @rajanmodanwal7479
    @rajanmodanwal7479 Před 2 lety +1

    CONGRATULATIONS BHAIYA FOR 300 K👍👍❤

  • @mohammedwaseem8599
    @mohammedwaseem8599 Před 2 lety

    Congratulations on 200k subscribers.

  • @hari_1357
    @hari_1357 Před 2 lety +1

    Thanks 👍

  • @nandiniverma5273
    @nandiniverma5273 Před 2 lety

    very helpful bhaiya

  • @gopichinthagumpula6481

    Congratulations Bhai.. For 200k.❤

  • @milenitrivedi7561
    @milenitrivedi7561 Před 2 lety +5

    Cant code the second solution in CPP, there is no function to pop elements with value, we can only pop the min or max element from 2 types of priority queues.
    If there is any code of second approach in c++ kindly help.

    • @kalpeshsaubhri
      @kalpeshsaubhri Před rokem

      I have the same doubt. Lets say even if it is there, then it is not a question of heap exactly.

  • @Yashjadhav-g2m
    @Yashjadhav-g2m Před 2 dny

    Hello Anuj Bhaiya , I want to buy you an coffee! thanks for the videos

  • @bharattalks4all
    @bharattalks4all Před 2 lety +2

    Congratulations bhaiya for 200k subscriber. I have one question
    Bhaiya agar kisi k paas software engineer ki degree nhi ho aur wo agar skill ke base pr kisi startup ya kisi choti company mein sde-1 ki job kr leta hai to kya iske base pr usey Google Microsoft ya Amazon mein job mil skti hai.
    Please reply

  • @azeezmoiz9195
    @azeezmoiz9195 Před 2 lety +1

    You could also solve this using segment trees, for the people who ain't aware of deque ds

  • @SukhmanSinghSandhu
    @SukhmanSinghSandhu Před rokem

    this video is helpful

  • @anshumaan1024
    @anshumaan1024 Před 11 měsíci +3

    In 2nd approach, In C++, we can't delete given value in heap 🙄

    • @isseihyodou7111
      @isseihyodou7111 Před 6 měsíci

      yes, you cannot delete a value from a heap, what you have to do is, store a vector, with value and index, and check whether the index of the element at the top of heap, is inside of the window or not, if not, then you need to pop it

  • @Rajeevkumar-sx3er
    @Rajeevkumar-sx3er Před rokem

    congrats on 400k anuj bro

  • @ShubhamKumar-pv8pj
    @ShubhamKumar-pv8pj Před 2 lety +6

    Random deletion of element in priority queue is possible in cpp.
    If yes, how ?

  • @deepjyotidebnath4122
    @deepjyotidebnath4122 Před 2 lety +2

    bhaiya add more video's frequently and u told that u add one video per day, try to make that.....

  • @yashmandaviya1356
    @yashmandaviya1356 Před 2 lety +3

    why there is no .remove() function for the priority queue in the c++?

    • @hameedmulani21
      @hameedmulani21 Před rokem +1

      Same happened with me, have you solved it by heap?

  • @tanaykamath1415
    @tanaykamath1415 Před 2 lety +2

    deleting an arbitrary element from the heap takes more than logarithmic time

  • @sagarnair9021
    @sagarnair9021 Před rokem

    bhai bhaari sikhate ho aap

  • @rohitayal2
    @rohitayal2 Před 2 lety +17

    Isn’t random element deletion in priority queue a O(n) operation? how can time complexity of 2nd solution be O(n log k) then

    • @ankurssharma96
      @ankurssharma96 Před 2 lety +4

      Having the same doubt, for root element deletion takes O(log N) how will it be same for any other random element. One needs to iterate all k elements to get the one that needs to be deleted.

    • @jaideepsingh7955
      @jaideepsingh7955 Před 2 lety +1

      @@ankurssharma96 ++

    • @ruhinapatel6530
      @ruhinapatel6530 Před 2 lety +1

      2nd solution ie remove(object) in priority queue is O(N). The time complexity is quadratic and gives TLE . I have tried the code..

    • @blueline2694
      @blueline2694 Před rokem

      O(logn) for tree.

    • @pokeindia5361
      @pokeindia5361 Před rokem

      There is no function to remove elements other than top in priority queue

  • @vaibhavdeshmukh7900
    @vaibhavdeshmukh7900 Před 2 lety +5

    Deletion of a random element from the heap takes O(n) time, right?
    How can it be O(log n)?

    • @psycho_gaming2422
      @psycho_gaming2422 Před rokem

      Max heap h

    • @kalpeshsaubhri
      @kalpeshsaubhri Před rokem

      @@psycho_gaming2422 bhai random element bol raha hai wo, random kaise search kar lega koi BST thode hi hai ye.

  • @raghavdwivedi111
    @raghavdwivedi111 Před rokem

    nice

  • @tanzeelahmed2055
    @tanzeelahmed2055 Před 2 lety +3

    How to think of edge cases in programming? I really suck at this!

  • @deepjyotidebnath4122
    @deepjyotidebnath4122 Před 2 lety

    Add videos on graph data structure🙏🙏

  • @mandarsadgir5256
    @mandarsadgir5256 Před 2 lety +1

    Bhai Doubly linked list ka create, insert,delete,display ka ek video bana do please🙏

  • @rajkumarm526
    @rajkumarm526 Před 2 lety

    I am waiting for 500K!

  • @arpanmaheshwari2290
    @arpanmaheshwari2290 Před 2 lety +3

    hum first

  • @chandlerformymonica2301
    @chandlerformymonica2301 Před 2 lety +1

    Deque solution taking O(n*k) because for every element we are checking is there any smaller element then that so it take O(n*k) right?.....Please Anuj Bhaiya Clarify!!!!

  • @utkarshsharma1867
    @utkarshsharma1867 Před měsícem

    sir aapne bola ki useful element vo hoge jiske left me uss se chote element nahi hoge...so in case of 2 3 2 only 3 should be useful element?

  • @shoyaishida3605
    @shoyaishida3605 Před 2 lety

    we can use multiset as well right ?

  • @ruhinapatel6530
    @ruhinapatel6530 Před 2 lety

    PriorityQueue solution is not NlogK.. It is NK ie quadratic..This solution gives TLE

  • @priyamshah7117
    @priyamshah7117 Před 2 lety

    in AVL tree or in the deque approach - once we computed max for 1st window why then in next for loop we again start from I=0 ?? 1st window is already done start from I=k

  • @AryanKumar-im1eg
    @AryanKumar-im1eg Před 2 lety +4

    Third 🤭

  • @mithleshkumar-ds9ex
    @mithleshkumar-ds9ex Před rokem +1

    bhaiya priority_queue se toh iska output galat ayega

  • @satyammishra6356
    @satyammishra6356 Před 2 lety +2

    Second🤭

  • @monti242421
    @monti242421 Před 11 měsíci

    deque approch : in increasing order, its complexity becomes (n+k) again

  • @kuldeepchauhan9359
    @kuldeepchauhan9359 Před 2 lety +3

    fist like

  • @yogeshdharya3857
    @yogeshdharya3857 Před rokem +2

    🤣 0:26 Dunda 🤣

  • @chandnibhatia1211
    @chandnibhatia1211 Před 2 lety

    Qi.peek()

  • @kiranmoymondal4050
    @kiranmoymondal4050 Před 2 lety

    Next video kab ayega?

  • @satvik0099
    @satvik0099 Před rokem

    Can you pls tell me what is the initial value of i in 2nd loop

  • @NehaVerma-il1us
    @NehaVerma-il1us Před 2 lety

    bhaiya kab tak finish hojayega ye course

  • @namanagarwal3186
    @namanagarwal3186 Před 2 lety

    Abe yaar ye i-k waala concept samajh nhi aa rha Deque waali approach me
    Bhaiya pls tell why we are writing dq.front()

  • @sanyammadaan2396
    @sanyammadaan2396 Před 2 lety

    Why are we adding index's ?

  • @udhayasankar113
    @udhayasankar113 Před 2 lety

    Pls add subtitles

  • @nittinrana2277
    @nittinrana2277 Před 2 lety

    200K

  • @kushalkapoor8490
    @kushalkapoor8490 Před 2 lety

    Anyone doing the code in python???

  • @User-ik1vq
    @User-ik1vq Před 2 lety +2

    *Keya sir ??? AAP SILF ENGINEERS / BCA / MCA logo ke liye video banate ho ?? Hum non-IT wale jo students IT mei passionate hai....unlogo ke liye nhi banate ho 😔😔.*
    *Aise bohot talented students hai jo IT mei jana chahta hai but paise ka kami ke wajay se IT degree (**B.tech/** BCA / MCA ) nhi kar paye. But the sad reality is no SO CALLED BIG CZcamsR talks about us.*

  • @dhananjaykumar6397
    @dhananjaykumar6397 Před 2 lety +1

    Congratulations bhiayaaaaaa... Keep going... Thankyou for all this videos bhaiya...
    Please do accept my message request on Instagram I needed to talk to you..