No video

215. Kth Largest Element in an Array | Day 014 | 3 Ways | Quick Select | Min Heap | Sorting

  Рет қаралды 2,056

Aryan Mittal

Aryan Mittal

Күн бұрын

In this video, I'll talk about how to solve Leetcode 215. Kth Largest Element in an Array
Checkout DSA-169 Series: • Aryan DSA-169 Series |...
100Days 100k Placements: • 100 Days 100K Placement
Let's Connect:
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / ez.pz.dsa
📱Telegram : t.me/aryan_mittal_group
🤖 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 :)
✨ Timelines✨
0:00 - Problem Explanation
1:18 - Approach1 - Sorting
2:32 - Approach2 - Min Heap (Priority Queue)
6:52 - Approach3 - Quick Select Algorithm + (Worst Case O(n) concept)
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Пікірлер: 15
@gauravpunia4527
@gauravpunia4527 6 ай бұрын
bro this code give me tle
@gauravpunia4527
@gauravpunia4527 6 ай бұрын
class Solution { public: int partition(int low,int high,int pivot_index,vector&arr) { int pivot=arr[pivot_index]; swap(arr[high],arr[pivot_index]); int store_index=low; for(int i=low;i < high;i++) { if(arr[i] < pivot) { swap(arr[i],arr[store_index]); store_index++; } } swap(arr[high],arr[store_index]); return store_index; } int findKthLargest(vector& arr, int k) { int low=0; int high=arr.size()-1; int n=arr.size(); while(true) { int pivot_index=rand()%(high-low+1)+low; int new_pivot=partition(low,high,pivot_index,arr); if(new_pivot==(n-k))return arr[new_pivot]; else if(new_pivot > n-k) high=new_pivot-1; else low=new_pivot+1; } } };
@sanskardhyani4112
@sanskardhyani4112 6 ай бұрын
same brother tle
@ARYANMITTAL
@ARYANMITTAL 6 ай бұрын
Yaa, true that can TLE, as its worst case is O(n^2), although Before Oct 2023 it was passing, but LC added some Test Cases thus its giving TLE, but this approach is for Interviews & its average & best case is O(n) . So, ignore Leetcode verdict for Quick Select algo, what we have is the best possible solution, yaa apart from using Median of Median🙃
@user-fs8km9qc8f
@user-fs8km9qc8f Ай бұрын
very nice explanation
@dhruvrawatt9
@dhruvrawatt9 6 ай бұрын
Aryan bhaiya you are the best 🙏
@sriramphysics5853
@sriramphysics5853 7 ай бұрын
Excellent explanation
@harshal8781
@harshal8781 6 ай бұрын
who logn is the SC for c++?
@abc-ym4zs
@abc-ym4zs 6 ай бұрын
Bhaiya I am in third year should I need to learn this approaches mainly some mainly asked interviewer questions or should I need to learn in last two months of placment bhaiya any suggestions bhaiya literally I am not getting interest when I am solving these problems bhaiya
@lilgainz
@lilgainz 6 ай бұрын
You need to bro
@abc-ym4zs
@abc-ym4zs 6 ай бұрын
@@lilgainz are u getting interest in it can u tell me how to develop interest in it
@lilgainz
@lilgainz 6 ай бұрын
@@abc-ym4zs brother don't take it like you have to solve a problem you should feel it like a game, thrill while solving codes for this you can start playlists on leetcode on different topics and make a deadline for it also you can start giving contests it provides you with a competitive environment fir aisa hota hai ki kro yaar krte rho.... Ye question ho kyu ni rha ... Kaise optimise kru.... Then you'll be more interested in learning optimal approaches
@abc-ym4zs
@abc-ym4zs 6 ай бұрын
@@lilgainz i started solving striver a to zost of the time when I read leetcode solutions not understanding and watching yt videos for every problem
@lilgainz
@lilgainz 6 ай бұрын
@@abc-ym4zs bro ik it can be frustrating in the start but you know what eventually you'll be able to solve by yourself and then you'll watch the solution video not for the solution but for the optimal approaches, just keep grinding and always watch you questions completed bar that gives you a lot of motivation. Tip: make one liner notes for every question you solve in that sheet helps alot in revision
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 790 М.
لااا! هذه البرتقالة مزعجة جدًا #قصير
00:15
One More Arabic
Рет қаралды 50 МЛН
UNO!
00:18
БРУНО
Рет қаралды 4,1 МЛН
Jonathan Blow on computer science curriculum
8:36
Anton Swifton
Рет қаралды 86 М.
Every Sorting Algorithm Explained in 120 minutes (full series)
1:57:33
Kuvina Saydaki
Рет қаралды 56 М.
Why I Quit Netflix
7:11
ThePrimeagen
Рет қаралды 496 М.
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 387 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 423 М.
What is a Monad? - Computerphile
21:50
Computerphile
Рет қаралды 599 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 349 М.
C++ Should Be C++ - David Sankel - C++Now 2024
1:28:49
CppNow
Рет қаралды 9 М.