Тёмный

Count Inversions in an Array | Brute and Optimal 

take U forward
Подписаться 623 тыс.
Просмотров 181 тыс.
50% 1

Problem Link: bit.ly/3GJcuYj
Notes/C++/Java/Python codes: takeuforward.org/data-structu...
We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.
Full Course: bit.ly/tufA2ZYt
You can follow me across social media, all my handles are below:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
0:00 Introduction of Course
00:40 Problem Statement
02:11 Brute force approach
02:52 Pseudocode
03:35 Complexity
04:05 Optimmal solution
04:22 Intuition
10:33 Approach + Dry-run
18:02 Code
22:37 Complexity

Опубликовано:

 

28 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 196   
@takeUforward
@takeUforward 10 месяцев назад
Please watch our new video on the same topic: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-AseUmwVNaoY.html
@namannema3349
@namannema3349 8 месяцев назад
this link take u to the same video we are watching
@yogeshkaushik8316
@yogeshkaushik8316 3 месяца назад
@@namannema3349 thats what recursion means
@satvrii
@satvrii Год назад
Nowadaya strivers voice has become so calm and soft 😅❤
@anuradha3868
@anuradha3868 10 месяцев назад
True...as compared to his previous vdos 😂
@newsbuster2194
@newsbuster2194 9 месяцев назад
😂
@shubhamkumar-hx1fb
@shubhamkumar-hx1fb 7 месяцев назад
​@@anuradha3868 same thought 😂
@saswatrath4646
@saswatrath4646 3 месяца назад
abe mic kharap tha pehle😂
@anuplohar23
@anuplohar23 6 месяцев назад
Best count inversion video on RU-vid, your method of teaching is very best that it gets me understand very easily 🌟🌟🌟
@_AASHISHSHAH
@_AASHISHSHAH Год назад
this is the best playlist in world. thank you stiver for your effort.
@cinime
@cinime Год назад
Understood! Super amazing explanation as always, thank you very very very much for your effort!!
@SuvradipDasPhotographyOfficial
The best count inversion video on RU-vid.. Thanks a lot Raj.. stay blessed❤
@gajendrakumar8271
@gajendrakumar8271 3 месяца назад
Finally completed this recursion playlist and Thanks a lot striver for great explanation throughout and patiently drawing recursion tree. patience is the key to solve and teach anything . And you have it man and you are teaching that too. Thanks a lot again
@bmishra98
@bmishra98 17 дней назад
Completed the playlist. This was the best recursion playlist I ever went through. Thanks a lot Striver.
@Manishgupta200
@Manishgupta200 Год назад
I'm trying this problem and solved it by myself by taking count as global variable.. But you taught us in a vary optimal way without taking count as a global variable. Really best optimal approach. Thankyou ❤
@bishakhdutta8427
@bishakhdutta8427 Год назад
whats the complexity of your solution? can you share it?
@Manishgupta200
@Manishgupta200 Год назад
@@bishakhdutta8427 same as merger sort merge algorithm
@senseiAree
@senseiAree 10 месяцев назад
Striver your voice is very soothing and calm bro ❤.... I use it to sleep at night AND study... and I don't feel sleepy
@vikasbagri1225
@vikasbagri1225 Год назад
Understood it very well Thanks for this amazing series
@akritisneh2849
@akritisneh2849 Год назад
So much crystal clear!!!!Thank youu❤
@prateekgoyal7009
@prateekgoyal7009 Год назад
This is the best explanation I've ever got.
@selvaarumugam370
@selvaarumugam370 Год назад
As usual your teaching jus made coding much easier than it is bruh!! Waiting for Binary Search series bruh!!!!
@cartidise
@cartidise Год назад
I usually don't comment but wanted to say that just subbed your channel. This is the best explanation I've ever got. THANKS A LOT:>)
@pallavi22222
@pallavi22222 Год назад
your problem solving approach explanation is superb
@user-jm6bc3rt5e
@user-jm6bc3rt5e 2 месяца назад
Understood THE BEST EXPLANATION Excellent playlist 👌 👏 ❤
@aditijagtap7853
@aditijagtap7853 12 дней назад
Best teaching approach so far!!!!
@chiragbirla5606
@chiragbirla5606 Год назад
Best explanation ever for this problem
@shiveshgupta1705
@shiveshgupta1705 Год назад
i just imagine if all the problems would be available on this channel in future
@mohd786ishaan
@mohd786ishaan 11 месяцев назад
UNDERSTOOD SIR ! GREAT EXPLAINATION
@lakshaysawhney9988
@lakshaysawhney9988 20 дней назад
Thoroughly enjoyed the problem!!
@unnatishukla8513
@unnatishukla8513 11 месяцев назад
awesome as always!!!!🤩
@SaumyaSharma007
@SaumyaSharma007 Год назад
OMG Bawal explanation Striver Bhaiya.😃
@mehulthuletiya497
@mehulthuletiya497 Год назад
Timestamps: --------------------- 00:40 Problem Statement 02:11 Brute force approach 02:52 Pseudocode 03:35 Complexity 04:05 Optimmal solution 04:22 Intuition 10:33 Approach + Dry-run 18:02 Code 22:37 Complexity
@prateek5208
@prateek5208 4 дня назад
such an awesome expalination bhaiya just approach dekhkr hi dimag ma intution agya ki merge ma kase implement krenge , you are best
@theresilientpianist7114
@theresilientpianist7114 6 месяцев назад
Really it was a great series Striver.🔥🔥
@ishangujarathi10
@ishangujarathi10 9 месяцев назад
loved the optimal solution, intuition op!
@GuruPrasadShukla
@GuruPrasadShukla Год назад
understood the approach sir thanks alot
@Sumeet_100
@Sumeet_100 7 месяцев назад
Thank you for this video !!
@pavanjegurupati
@pavanjegurupati 4 месяца назад
Great explanation!!
@sukhpreetsingh5200
@sukhpreetsingh5200 Год назад
Understood amazing explanation
@gauristar4094
@gauristar4094 23 дня назад
Superb logic, Understood!!!
@abhaypatel379
@abhaypatel379 Месяц назад
thanks striver for making a complex question into very easy question 🤗
@xtzyrox2764
@xtzyrox2764 Год назад
I am happy with the brute force now I will see optimal 1 week before interview bcz University exams are in this month
@b39_navkaransingh73
@b39_navkaransingh73 Год назад
Did anyone ask you?
@sivasaimanchem4399
@sivasaimanchem4399 Год назад
All i can say is Thankyou so much ❤🙌
@8bit_hero850
@8bit_hero850 4 месяца назад
Can we realistically solve this if it comes in an interview given we haven't solved it before? I mean how do can you get the intuition of merge sort from this problem? I really don't get it.
@unknown47896
@unknown47896 8 дней назад
no way bro
@HR-pz7ts
@HR-pz7ts 3 месяца назад
Amazing I solved two questions using the same logic.
@NazeerBashaShaik
@NazeerBashaShaik 4 месяца назад
Understood, thank you.
@saitehith6647
@saitehith6647 Год назад
Superb Explanation
@vaibhav56
@vaibhav56 18 дней назад
I was struggling with the solution but as soon as you mentioned merge sort it clicked in my mind
@abhishekverma4693
@abhishekverma4693 5 месяцев назад
thank you so much for watching
@steverogers7050
@steverogers7050 4 месяца назад
very nice explanation bhaiya
@ishasinghal3457
@ishasinghal3457 7 месяцев назад
Best explanation ever
@rohitkumarpilania94
@rohitkumarpilania94 Год назад
Badhiya kaam kar rahe ho, see you soon
@hashcodez757
@hashcodez757 4 месяца назад
understood Bhaiya!!
@muqeemuddin8057
@muqeemuddin8057 5 месяцев назад
Hey, can you make a video on binary insertion sort and compare it's time complexities with insertion sort. Thanks for your videos on DSA.
@AbjSir
@AbjSir 9 месяцев назад
// Everytime while sorting you move an element to the left (assume nobody moves to right agar chote walo ko aana hoga to left me aa jayenge) // if an element crosses another element while moving to the left for the purpose of sorting then it should increase the count of inversion
@yashisrivastava6196
@yashisrivastava6196 11 месяцев назад
just wow explanation
@user-ck6kn1ty8x
@user-ck6kn1ty8x 5 месяцев назад
Thank You Bhaiya
@sarangkumarsingh7901
@sarangkumarsingh7901 4 месяца назад
Nice lecture................
@ShubhamKumar-uf3gc
@ShubhamKumar-uf3gc Месяц назад
loved that bhaiya
@grm642
@grm642 5 месяцев назад
Thank you😊
@the_haryannvi_coder
@the_haryannvi_coder 2 месяца назад
If u don't wanna use cnt in mergeSort function, you can do this:- int mergeSort(vector &arr, int low, int high) { if (low >= high) return 0; int mid = (low + high) / 2 ; int left = mergeSort(arr, low, mid); // left half int right = mergeSort(arr, mid + 1, high); // right half int m = merge(arr, low, mid, high); // merging sorted halves return left + right + m; }
@venup2813
@venup2813 Год назад
Understood brother❤️
@navdeepkumar9160
@navdeepkumar9160 Год назад
Great video
@ravalikatalks5285
@ravalikatalks5285 6 месяцев назад
thanks alot bhaiya
@NoniSabharwal
@NoniSabharwal 3 месяца назад
The way he said wow! Uff in love with the voice
@anshasati1920
@anshasati1920 Месяц назад
Understood Sir🥳
@YourCodeVerse
@YourCodeVerse 8 месяцев назад
Understood✅🔥🔥
@nishant4595
@nishant4595 Месяц назад
understood!!!
@addy1268
@addy1268 6 месяцев назад
can anybody pls explain why we cant/ should'nt declare the 'cnt' variable globally ?
@ChhaviAayushi-qh4zx
@ChhaviAayushi-qh4zx Год назад
Good Afternoon sir sir in my college it's hard to get on campus INTERNSHIP can you please advice so that I can get an internship in my third year . Thanks
@abhishekahirvar7783
@abhishekahirvar7783 2 месяца назад
thanks mate
@nikhilprakashahir5730
@nikhilprakashahir5730 5 месяцев назад
so aweesome
@satyamgupta4808
@satyamgupta4808 10 месяцев назад
very nice video
@atharva3571
@atharva3571 7 месяцев назад
I understood the problem
@GhostVaibhav
@GhostVaibhav 5 месяцев назад
Understood🔥
@TheNullDeveloper
@TheNullDeveloper 27 дней назад
understood the solution . But how do i get the intution that it will solve in this way i.e using this approach 😕 in most of the cases i don't have idea about the optimal one how would I approach it
@divyaanandhan6021
@divyaanandhan6021 Год назад
Thanks 😊👍
@her_soulmate
@her_soulmate 8 месяцев назад
Understood 🎉
@HarshChoudhary-vm6eh
@HarshChoudhary-vm6eh Год назад
Understood thats great...
@VaibhavSethF
@VaibhavSethF 2 месяца назад
Hi Striver , is creating static variables in interview is a bad practice?
@hetchaudhari
@hetchaudhari Месяц назад
Is it fine to pass variables by reference?Or should we avoid that too in the interviews?
@vikasgupta1828
@vikasgupta1828 Год назад
Thanks
@user-je7tz6le4k
@user-je7tz6le4k Год назад
These types of questions always demotivate me... like how you can think of such kind of solution in an interview
@user-nk1mb5fy7j
@user-nk1mb5fy7j Год назад
UNDERSTOOD
@RIyaGupta-iz9iw
@RIyaGupta-iz9iw 4 дня назад
Understand bhaiya
@RituSingh-ne1mk
@RituSingh-ne1mk 7 месяцев назад
Understood!
@varunpalsingh3822
@varunpalsingh3822 Год назад
understood 👍👍
@vivekbhore5722
@vivekbhore5722 3 месяца назад
thank u striver
@hemantpatel1413
@hemantpatel1413 Месяц назад
understood.
@infomania_by_ayush7901
@infomania_by_ayush7901 Месяц назад
Understood, but I am gonna need some time to implement this.
@infomania_by_ayush7901
@infomania_by_ayush7901 Месяц назад
Implemented.
@user-lw9dj8we7k
@user-lw9dj8we7k 7 месяцев назад
Understood sir
@culeforever5408
@culeforever5408 9 месяцев назад
understood :)
@vk-mc5tq
@vk-mc5tq 3 месяца назад
Global vs Local In Global variables values updated dynamically but in local variables we need to pass updated values (manually) to subsequent functions
@nayankhuman1043
@nayankhuman1043 19 дней назад
Understood :)
@mount2020
@mount2020 Год назад
Thank u bhai
@MJBZG
@MJBZG Месяц назад
didn't understand much but will try again
@mridulathya1201
@mridulathya1201 6 месяцев назад
Should'nt the line at 19:30 be "cnt += (mid - left + 1) - i "
@ajaykr2811
@ajaykr2811 10 месяцев назад
13:05 the kind of excitement I want while learning DSA.
@pritipatil4021
@pritipatil4021 Год назад
Understood...!!!!
@himanshidafouty347
@himanshidafouty347 Месяц назад
Understood
@error-my9ut
@error-my9ut Год назад
understood this but sir i am not really sure that if it would hit in my head at the time of interview how can i make that sure sir
@vaibhavverma6120
@vaibhavverma6120 9 месяцев назад
you cansolve these type of questions if only you have done it or similar type of question earlier otherwise no one can get this intuition on the spot.
@shashankvashishtha4454
@shashankvashishtha4454 Месяц назад
understood
@soumiyamuthuraj3516
@soumiyamuthuraj3516 Месяц назад
awesome
@hardikg6858
@hardikg6858 4 месяца назад
can i solve this question using pbds
@MasterChief-jy2zg
@MasterChief-jy2zg Месяц назад
I tried it in a new approach. 2 pointer method. time complexity is near about O(n). but don't know why it is showing O(n^2) striver can u help me? int numberOfInversions(vector&a, int n) { int cnt=0,left=0,right=left+1; while(left < (n-1)){ if(right == n){ left++;right=left+1; } else if(a[left] > a[right]){ cnt++;right++; } else right++; } return cnt; }
@garimajain4410
@garimajain4410 4 дня назад
can anyone tell me..........................merge vala function private main kyun likhenge aur inversion vala public main kyunnn likhenge . if will not do so then saare testcases pass nhi ho rhe
@yaswanthkosuru
@yaswanthkosuru 10 месяцев назад
how to solve these without seeing before in interview
Далее
Reverse Pairs | Hard Interview Question
32:26
Просмотров 116 тыс.
РУБИН - ЗЕНИТ: ВСЕ ГОЛЫ
01:03
Просмотров 197 тыс.
Java Is Better Than Rust
42:14
Просмотров 172 тыс.
Roblox Is Getting Worse On August 7th...
8:34
Просмотров 703 тыс.
How I would learn Leetcode if I could start over
18:03
Просмотров 376 тыс.
8 patterns to solve 80% Leetcode problems
7:30
Просмотров 273 тыс.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
РУБИН - ЗЕНИТ: ВСЕ ГОЛЫ
01:03
Просмотров 197 тыс.