3193. Count the Number of Inversions | DP Time Complexity | Two Pointer | DP Space Optimized
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
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
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!!
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.
yes.
it was never fun in the first place
@@MrKB_SSJ2 if you'll always think about ratings , then it will never be
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
Thnks for the video man
Brilliant! :o
Do continue the good work :)
58 seconds ago is oddly satisfying
Seeing this comment on just post of video is also oddly satisfying 🌚❤️
@@ARYANMITTAL if in the next 4 years i aint you then its all a waste😤
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).
The difference also becomes apparent when prefix sum for the inner loop is used (620ms vs 8000ms)
this code is failing on the last test case on leetcode
Bro you are right i have seen so such same code
do they not get plag ? or accounts dont get blocked because of cheating ?
@@thats.my.prompt
They will be, if they violate/cheat twice.
For first time only leetcode coins reset and discussion ban for 1 month
@@thats.my.prompt
Yes if violated/cheated twice
sir aap itna complex logic kaise soch lete hai.
q3 sol?
Bro.. literally kuchh samajh nahi aa raha! :(
But I solved first 3 questions in less than 8 minutes 😆
😢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😅
Haan, first three was comparatively kaafi easy than this 4th, it needed a lot of pen & paper & a lot of scribbling 😮💨💀
Hey whats your leet id?
Did 3 questions within 16-17 mins but couldn't solve 4th as I had to go to birthday partry.
Bro hurried to comment just to flex 😂.
@@rajrajesh1669 nah people did in 3 mins bro I am slow
What Is your profile buddy on LC
Bhaiya 3rd ques ka soln chahiye plz...
int minOperations(vector& a) {
int c = 0;
for(int i: a) {
if((i+c) % 2 == 0) c++;
}
return c;
}
@@rushirajparekh9079bhai yeh kya hai 😭😭... 3rd ka soln chahiye tha bhai XD
Ha bhai ye 3rd ka hi solution hai!
@@rushirajparekh9079 Not working bhai... also it was long long not int
@@rushirajparekh9079 also is this from DP topic? coz i havent done that...
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.
can you explain why?
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.😊
Good morning at 12:00 night ??
🌚🌚
hindi mei samjha diya karo bhai tum