3193. Count the Number of Inversions | DP Time Complexity | Two Pointer | DP Space Optimized

Sdílet
Vložit
  • čas přidán 21. 06. 2024
  • In this video, I'll talk about how to solve 3193. Count the Number of Inversions | DP Time Complexity | Two Pointer | DP Space Optimized
    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 • 43

  • @ARYANMITTAL
    @ARYANMITTAL  Před měsícem +13

    1 Like ❤ = 1 HR replying you back 🌚
    .
    Jokes apart, do let me know in comments what all you learned & what did you guys miss in this problem, that's how you will learn (by recalling your mistakes)
    .
    When are you ready for FAANG - czcams.com/video/h71X1VMo5J0/video.html

  • @adwaitkakad4903
    @adwaitkakad4903 Před měsícem +8

    Please think about starting the hard level problems especially dp problm with the recursive approach and then convert it to iterative dp ( explain approach and code ...recursive approach )...this will help newbie understand the problem more easily and will keep them watching till end!!

  • @ujjwalagnihotri5001
    @ujjwalagnihotri5001 Před měsícem +22

    People are solving easy questions using Chat GPT and cheating in the harder problems. They have literally spoiled the fun of competing and brainstorming ideas.

  • @pranshu_awasthi
    @pranshu_awasthi Před měsícem +2

    I would again emphasize on the same thing.
    A big big big suggestion which you should definitely incorporate in your teaching.
    1. Please do not pre-write everything on your tab, make sure to write notes on the fly while recording.
    2. Please do not over-explain things, you tend to over-explain so much that the MAQSAD is usually lost in between.
    3. Try to break solutions in sub parts, write the explanation on the fly and make sure the writing is minimal and less like story.
    4. Please keep the video short & concise.
    Thanks

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

    Thnks for the video man

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

    Brilliant! :o
    Do continue the good work :)

  • @Kauliflower-yl8te
    @Kauliflower-yl8te Před měsícem +7

    58 seconds ago is oddly satisfying

    • @ARYANMITTAL
      @ARYANMITTAL  Před měsícem +6

      Seeing this comment on just post of video is also oddly satisfying 🌚❤️

    • @Kauliflower-yl8te
      @Kauliflower-yl8te Před měsícem

      @@ARYANMITTAL if in the next 4 years i aint you then its all a waste😤

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

    I still think the complexity is O(n^2 * 400). You are right that recusive values will be memoized but to compute each of those values (even for the first time), the for loop will be executed prefi times (in worst case).

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

      The difference also becomes apparent when prefix sum for the inner loop is used (620ms vs 8000ms)

  • @mohd.vaseem7410
    @mohd.vaseem7410 Před měsícem

    this code is failing on the last test case on leetcode

  • @HarshKumar-xw5nn
    @HarshKumar-xw5nn Před měsícem

    Bro you are right i have seen so such same code

    • @thats.my.prompt
      @thats.my.prompt Před měsícem +1

      do they not get plag ? or accounts dont get blocked because of cheating ?

    • @rajrajesh1669
      @rajrajesh1669 Před měsícem +1

      ​@@thats.my.prompt
      They will be, if they violate/cheat twice.
      For first time only leetcode coins reset and discussion ban for 1 month

    • @rajrajesh1669
      @rajrajesh1669 Před měsícem +1

      @@thats.my.prompt
      Yes if violated/cheated twice

  • @ayushkumar-ew9wu
    @ayushkumar-ew9wu Před měsícem

    sir aap itna complex logic kaise soch lete hai.

  • @jaypatel-rm8sc
    @jaypatel-rm8sc Před měsícem

    q3 sol?

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

    Bro.. literally kuchh samajh nahi aa raha! :(
    But I solved first 3 questions in less than 8 minutes 😆

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

    😢i solved first 3 question in less than 20 minutes, and could not solve thid Q4😅 wrote the brute force approach of next_permutation and stuff, TLE aya😅

    • @ARYANMITTAL
      @ARYANMITTAL  Před měsícem +2

      Haan, first three was comparatively kaafi easy than this 4th, it needed a lot of pen & paper & a lot of scribbling 😮‍💨💀

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

      Hey whats your leet id?

  • @-lyxics
    @-lyxics Před měsícem

    Did 3 questions within 16-17 mins but couldn't solve 4th as I had to go to birthday partry.

    • @rajrajesh1669
      @rajrajesh1669 Před měsícem +5

      Bro hurried to comment just to flex 😂.

    • @-lyxics
      @-lyxics Před měsícem

      @@rajrajesh1669 nah people did in 3 mins bro I am slow

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

      What Is your profile buddy on LC

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

    Bhaiya 3rd ques ka soln chahiye plz...

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

      int minOperations(vector& a) {
      int c = 0;
      for(int i: a) {
      if((i+c) % 2 == 0) c++;
      }
      return c;
      }

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

      ​@@rushirajparekh9079bhai yeh kya hai 😭😭... 3rd ka soln chahiye tha bhai XD

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

      Ha bhai ye 3rd ka hi solution hai!

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

      @@rushirajparekh9079 Not working bhai... also it was long long not int

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

      @@rushirajparekh9079 also is this from DP topic? coz i havent done that...

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

    For People having WA.
    Swap the order of if conditions:
    Put
    if(prefi == 0) return cnt == 0;
    Condition After,
    if(j >=0 && req[j][0] == prefi) {.....}
    Condition.

    • @evanarafat9136
      @evanarafat9136 Před 7 hodinami

      can you explain why?

    • @shubhamverma1113
      @shubhamverma1113 Před 6 hodinami

      I don't perfectly remember, but, Because if (pref == 0 and j >= 0), and we don't have the request to solve further, i.e., (req[j][1] != cnt) we simply return 0. Or else, even if we don't have to solve we still return cnt==0, which may or may not be 0.
      If it makes any sense.😊

  • @italk-gj5kk
    @italk-gj5kk Před měsícem

    Good morning at 12:00 night ??

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

    hindi mei samjha diya karo bhai tum