Rolling Median | Median of all subarrays of fixed size | Leetcode Contest 122

Поділитися
Вставка
  • Опубліковано 5 лис 2024

КОМЕНТАРІ • 38

  • @dobariyavraj3659
    @dobariyavraj3659 5 місяців тому +2

    Today in Codechef 134 B i solved 3rd problem using it. It was amazing as you Sir.

  • @mdaasil2329
    @mdaasil2329 9 місяців тому +2

    I first thought of only heaps like the Median in a Data Stream problem. But sets here are much more effective. Thanks for the variations bro. Good stuff!

    • @abhishekcode42
      @abhishekcode42  9 місяців тому +4

      Yes, sets makes it relatively more convenient to solve variations, specially when we need to erase too.
      Glad it was useful.

  • @ashutoshraj7171
    @ashutoshraj7171 9 місяців тому

    Content tips
    Provide the video solution of hardest problem (D,E,F or G) after contest and the concept behind the question or why we choose any particular Data structure..
    This will be the new in youtube for those who are beginner and solve upto C type of questions , forget the fear of hard questions

  • @ShahKalash
    @ShahKalash 8 місяців тому +1

    Can you make a video on finding the accurate mediam of an array in O(N)?

  • @anprattech5525
    @anprattech5525 9 місяців тому +5

    Hi, I noticed you're planning a video on DSA problem-solving. I'd love to edit it for broader reach. I have 2+ years of editing experience, also worked with over 100k+ subs UA-camrs. If you want we can discuss it further

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      Yes, we can discuss this more. Can you ping me on discord?

    • @anprattech5525
      @anprattech5525 9 місяців тому

      ​@@abhishekcode42sure kindly share

    • @ananypratap
      @ananypratap 9 місяців тому +1

      Sure kindly share

    • @ananypratap
      @ananypratap 9 місяців тому

      ​@@abhishekcode42I am the same person

    • @abhishekcode42
      @abhishekcode42  8 місяців тому

      Aah okay, you can ping me here abhishek_saini#6544

  • @ramkumarsah7027
    @ramkumarsah7027 9 місяців тому

    Can u please provide the Fenwick tree playlist , when u use and when to use

  • @sudo29
    @sudo29 9 місяців тому +3

    Hi bhaiya I am learning dsa for around 7-8 months from youtube and gfg, done with ds, but from recursion and backtracking when i go to solve myself not able to find the intuition by own. How can I improve.

  • @AbhishekKumar-kk6qs
    @AbhishekKumar-kk6qs 9 місяців тому +2

    Hi Abhishek, like here about rolling median, what we should learn apart of standard algorithm, so that we can deal the hard problems easily, any portal which u would like to suggest.

    • @abhishekcode42
      @abhishekcode42  9 місяців тому +1

      One of the important part is understanding the standard version as well as possible and proofs etc. whenever possible. If one understand the well, then probability of solving a variation increases significantly.

  • @mranonymous8498
    @mranonymous8498 9 місяців тому

    And This can be done easily using ordered set (pbds) ?
    In Today's D (weekly)
    It would be easy if there was no special path from x and y couldn't come up with o(n)
    How do we solve ?

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      This can be solved using many things, even prioriry_queue too.
      Check out my code for today's D for O(n).

  • @yogeshagarwal403
    @yogeshagarwal403 9 місяців тому +1

    I am still not able to relate how the 4th problem was the 2nd variation

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      It's not variation two, it's combination of both variation 1 and 2.
      In 4th problem effectively you need to find sum of k - 1 smallest elements in all subarrays of size dis. That's the answer, check code in the description if you want to see exact implementation.

    • @yogeshagarwal403
      @yogeshagarwal403 9 місяців тому

      @@abhishekcode42 understood

  • @yogeshagarwal403
    @yogeshagarwal403 9 місяців тому

    is it the sliding window median problem?

  • @simply_arko
    @simply_arko 9 місяців тому

    One STL regarding doubt:
    Can you please tell me why in this line:
    left.erase(left.find(*left.rbegin()));
    a simple left.erase(left.rbegin()) is not working? It should right? Because multiset::erase() expects an iterator as a parameter, which in this case is left.rbegin()! Also in case of right.erase() its working.
    Am I missing something?

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      This happens because std::iterator and std::reverse_iterator are different. rbegin() returns std::reverse_iterator

    • @simply_arko
      @simply_arko 9 місяців тому

      @@abhishekcode42 Ohh...Got it! Thanks for clarifying😇

  • @mranonymous8498
    @mranonymous8498 9 місяців тому

    sir why are you adding last k elements (n-i-1 think) can't we do this using the first k elements
    And why are you erasing [dist+1+ind] th element if we are considering the Subarray of size dist

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      First K [Not first k though, you will need to skip first element as that is already taken) and last k are same thing.
      For your second problem, try running a dry example, that would become clearer.

  • @AaryanSingh-c4i
    @AaryanSingh-c4i 9 місяців тому

    Cab we use pbds to solve the problem?

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      Yes, Also priority_queue can also be used atleast for the asked problem by using some method to handle removing elements.

  • @yogenderyadav4550
    @yogenderyadav4550 9 місяців тому

    thanks bhaiya

  • @do_not_want_to_show
    @do_not_want_to_show 9 місяців тому

    Why do you sound highly experienced and newbie at the same time?

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      What do you mean? Are there mistakes in explanation?

    • @do_not_want_to_show
      @do_not_want_to_show 9 місяців тому

      I mean you have great knowledge and experience and still newbies like me can understand your explanation flawlessly.

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      Thanks, very encouraging to hear that.
      My goal is to consciously try to make explanations as simple as possible.
      Good to know it's already understandable, but hopefully should become even more clearer with time.

  • @tanujnainwal9266
    @tanujnainwal9266 9 місяців тому

    Can you please explain the approach and solutions of all the problems. I have found the approach but not able to code it.

    • @abhishekcode42
      @abhishekcode42  9 місяців тому

      Please try to check out my code for others, if something is not clear, you can ask here.

  • @abhishekc3556
    @abhishekc3556 9 місяців тому

    Thankss