Median Priority Queue - Solution | Hashmap and Heap | Data Structure and Algorithms in JAVA

Sdílet
Vložit
  • čas přidán 1. 08. 2020
  • Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
    NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we explain the solution to median priority queue in Hashmap.
    For a better experience and more exercises, VISIT: www.pepcoding.com/resources/o...
    #pepcoding #java #programming
    Have a look at our result: www.pepcoding.com/placements
    Follow us on our FB page: / pepcoding
    Follow us on Instagram: / pepcoding
    Follow us on LinkedIn: / pepcoding-education
    Join us on Telegram: t.me/joinchat/UVTjJE83a-zFnPB

Komentáře • 49

  • @Dizerfullpower
    @Dizerfullpower Před 3 lety +9

    Thanks a lot, I was assigned this problem with extremely vague description at school. As soon as you started coding, I got what they really asked me to do!

  • @stith_pragya
    @stith_pragya Před 3 měsíci +1

    Thank You So Much for this wonderful video.....🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @shivamsingh7219
    @shivamsingh7219 Před 3 lety +8

    Sir,even vale case mein median average of middle two hota hai
    Isiliye ek condition aur aaygi
    If(left.size()==right.size()){
    return. (left.peek()+right.peek())/2

  • @shivambhardwaj3273
    @shivambhardwaj3273 Před 2 lety

    Pure Gold!
    hats off to you sir!

  • @547julia
    @547julia Před 2 lety

    Thanks a lot! This seems so simple now and elegant too

  • @sarthakgiri4596
    @sarthakgiri4596 Před rokem

    you are elite sir! love from Nepal

  • @siddhantchowdhary2230

    great video sir,thanks a lot sir

  • @AmanKumar-bh6bc
    @AmanKumar-bh6bc Před 2 lety

    great explanation.

  • @KinnarKansara
    @KinnarKansara Před 3 lety +4

    You made it very easy to understand. Great job brother. Keep it up!

    • @Pepcoding
      @Pepcoding  Před 3 lety +3

      I am glad you liked it. I also hope that you are watching all the videos till the end and trying to understand the problem.
      Will you like to write a few words about us here (www.quora.com/What-is-a-good-source-to-learn-data-structures-and-algorithms)

  • @ankur.singhs2111
    @ankur.singhs2111 Před 4 lety +8

    Sir many students have just 3 month remaining in placements, so can you make a 3 months step by step roadmap to master DS Algo to crack good companies ?
    Much much needed sir.

    • @Pepcoding
      @Pepcoding  Před 4 lety +6

      The smallest plan i have needs 200 days.
      czcams.com/video/2IdlrHxdla4/video.html

  • @hjklmn9526
    @hjklmn9526 Před rokem

    Sumeet great explanation. I think when the number of elements in the max_heap (left_heap) and min_heap (right heap) is even, we take average value of the top elements from both heaps to get the median..

  • @AbhinandanSharmaiisc2017
    @AbhinandanSharmaiisc2017 Před 3 lety +1

    This is pure gold stuff

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Thankyou beta!
      I am glad you liked it. I hope that you are watching videos till the end. If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @suvamroy6205
    @suvamroy6205 Před 2 lety

    You're nothing less than a god. You're a life-saver.

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

      Hope you like the video.
      For better experience and well organised content sign up on nados.io
      And for being updated follow us on Instagram instagram.com/pepcoding/

  • @adarshsharmanit356
    @adarshsharmanit356 Před 3 lety

    Respect++
    NIce Explanation SIr !!

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Glad to know that you liked the content and thank you for appreciating.
      The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
      So, keep motivating, keep learning and keep loving Pepcoding😊

  • @rachelross9275
    @rachelross9275 Před 3 lety

    Excellent!😍

  • @rishabhgoyal9623
    @rishabhgoyal9623 Před 3 lety

    gazab explanation❤️

  • @rishabhgoyal2835
    @rishabhgoyal2835 Před 3 lety

    amazing , what abt time and space complexity

  • @LegitGamer2345
    @LegitGamer2345 Před 3 lety

    we are finding median here in increasing data ?

  • @fashionvella730
    @fashionvella730 Před 2 lety

    do this on my own i am very happy to sove hard question on my own

  • @architsharma4331
    @architsharma4331 Před 3 lety +1

    Sir I did this problem the same way we did in Queue to Stack Adapter(add efficient) question and it passed all the test cases as well

  • @rajshah9129
    @rajshah9129 Před 7 měsíci

    How to come up that we require 2 priority queue one of min and one of max pls give intuition also

  • @khemendrabhardwaj2552

    I think implementation with multiset in c++
    would be really simple
    especially the deletion part

  • @prahladrana6391
    @prahladrana6391 Před 3 lety

    sir what if the element to be added lies between both the current medians.. where it has to be inserted?
    like the moment where the medians were 20 and 30.. and the next no. coming up was to be 26 then where should it go?

    • @Pepcoding
      @Pepcoding  Před 3 lety +1

      chote wali mei. chahe usme already data jyada ho. balance ho jaega. jaise he do ka gap banta hai to wo balance karta hai

    • @prahladrana6391
      @prahladrana6391 Před 3 lety

      @@Pepcoding ok sir

  • @kagoel71
    @kagoel71 Před 3 lety +1

    Sir does this question belong to the catgory jisse ratna hain ie memory based or this belongs to coding aptitude category?As thinking of this solution that you prescribed was pretty tough.

    • @Pepcoding
      @Pepcoding  Před 3 lety +3

      Memory based

    • @codingwithanonymous890
      @codingwithanonymous890 Před rokem

      yes dude this solution really requires so much thought process...to come up with this solution in short span of interview

  • @iankush18
    @iankush18 Před 3 lety

    Bhai jab left m 3 hai or right m 3 hai toh dono mean lete hai naa

  • @shubhamsood1406
    @shubhamsood1406 Před 3 lety +1

    Atisundar ^_^

  • @NiranjanKumar-cb8si
    @NiranjanKumar-cb8si Před 4 lety

    this.size() == right.size()+left.size() ????? how is it working (this.size() ) ?

    • @Pepcoding
      @Pepcoding  Před 4 lety

      Beta, kaunse time pe? video mei time btaie.

  • @harshitkaushik4144
    @harshitkaushik4144 Před 3 lety

    sir jo aapne main function banaya hua bhai vo samjh nahi aata ki khud se apne tareke se kaise banaye same case linked list , stacks and queue me bhi hua tha
    ab ye bas aage khichta ja raha hai
    sir jaise aap bufferreder , quit , exit , and so on ka use karte ho vo samjh nahi aata ki agar use scanner aur apne tareke se banaye to kaise banaye
    ya fir interview me bhi aise hi aayega ki hume sirf ye 4 funtion hi banane honge

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Beta it's just the syntax, practice k sath apne aap yaad he ho jayega vo to

    • @harshitkaushik4144
      @harshitkaushik4144 Před 3 lety

      @@jonusbrothers2067 First they laugh at you then they set u as an example
      M also waiting for that moment brother
      Which is gonna happen soon

  • @sahilnegi2789
    @sahilnegi2789 Před 3 lety

    Sir Iam not able to think this logic ..

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

    Hindi thareyathu poda...

    • @sumitshokeen4065
      @sumitshokeen4065 Před 2 lety

      Hi Urkriskhnan, this same content is also available in English on nados