Least Number of Unique Integers after K Removals | 3 Approaches | Greedy | Leetcode 1481

  Рет қаралды 3,423

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 35
@EB-ot8uu
@EB-ot8uu 8 ай бұрын
I subscribed to your channel few days back and till now I think you are one of the best tutors I found on youtube for DSA. god bless you and thank you for covering all approaches.
@codestorywithMIK
@codestorywithMIK 8 ай бұрын
✨ Timelines✨ 00:00 - Introduction 0:18 - Problem Explanation 5:52 - Approach-1 Intuition 9:10 - Time and Space Complexity of Approach-1 9:58 - Important Note 12:51 - Coding Approach-1 14:50 - Approach-2 Explanation 16:39 - Time and Space Complexity of Approach-2 17:52 - Coding Approach-2 19:41 - Approach-3 Detailed Explanation 39:45 - Coding Approach-3
@oqant0424
@oqant0424 8 ай бұрын
Using your story--> code method , I solved it on my own Came here to see a better approach ❤❤
@Ankitkumar-fz3kc
@Ankitkumar-fz3kc 8 ай бұрын
Thanks for 3rd approach it's very difficult to come up with it but you made easy thanks.
@wearevacationuncoverers
@wearevacationuncoverers 8 ай бұрын
Nailed the 3rd Approach. Thanks a lot man. You always mesmerise me.
@aws_handles
@aws_handles 8 ай бұрын
I am a big fan of your explanation. Every time i learn something new. Thanks a lot for the 3rd approach
@gui-codes
@gui-codes 2 ай бұрын
Awesome explanation
@ishwarreddy8820
@ishwarreddy8820 8 ай бұрын
bhaiya aise hi guide karte rahiye boht help hota hai
@thekindspill
@thekindspill 8 ай бұрын
Was waiting for your upload, thank you mik❤️
@utkarshsahay9908
@utkarshsahay9908 8 ай бұрын
class Solution { public: int findLeastNumOfUniqueInts(vector& arr, int k) { unordered_map mpp; for(int num : arr) mpp[num]++; vector vec; for(auto it : mpp) vec.push_back(it); sort(vec.begin(),vec.end(),[] (auto a,auto b){ return a.second < b.second; }); int ans = vec.size(); for(auto &it : vec){ if(k >= it.second){ k -= it.second; } else if(k < it.second || k == 0){ break; } ans--; } return ans; } };❤❤
@revolverlim.6444
@revolverlim.6444 8 ай бұрын
just a suggestion give the similar qus as hw at the end and link of the similar question in the github
@codestorywithMIK
@codestorywithMIK 8 ай бұрын
sure thing.
@parthbhatti4151
@parthbhatti4151 8 ай бұрын
@@codestorywithMIK yes please 🙏
@bhuppidhamii
@bhuppidhamii 8 ай бұрын
yes
@devmadaan5146
@devmadaan5146 8 ай бұрын
No please no,😢
@rohitshah8904
@rohitshah8904 8 ай бұрын
Awesome explanation ❤ One doubt .. why k
@bitandutta3151
@bitandutta3151 8 ай бұрын
Thank you mik ❤
@tutuimam3381
@tutuimam3381 8 ай бұрын
Thanks a lot
@divyamdubey9333
@divyamdubey9333 8 ай бұрын
Bro video tags would be really helpful
@codestorywithMIK
@codestorywithMIK 8 ай бұрын
Sure thing Divyam. ✨ Timelines✨ 00:00 - Introduction 0:18 - Problem Explanation 5:52 - Approach-1 Intuition 9:10 - Time and Space Complexity of Approach-1 9:58 - Important Note 12:51 - Coding Approach-1 14:50 - Approach-2 Explanation 16:39 - Time and Space Complexity of Approach-2 17:52 - Coding Approach-2 19:41 - Approach-3 Detailed Explanation 39:45 - Coding Approach-3
@dipesh5293
@dipesh5293 8 ай бұрын
awsome
@oqant0424
@oqant0424 8 ай бұрын
Thanks bhaiya :)
@AmanKumar-qz4jz
@AmanKumar-qz4jz 8 ай бұрын
why only 18k subs.....man deserves lot more!!! guys please subscribe
@jagadeeshp1163
@jagadeeshp1163 8 ай бұрын
d={} for i in arr: d[i]=d.get(i,0)+1 count=len(d) arr.sort(key=lambda x:d[x]) cnt=0 for i in arr: cnt+=d[i] for i in range(k): t=arr.pop(0) d[t]-=1 if d[t]==0: count-=1 return count why is my code failing cases ?
@maritime_business
@maritime_business 8 ай бұрын
3rd approach toh interview ke time pe koi strike kar hi nhi paega, specially agar kisi ne phle se na kia ho there is no point in that specially that divide logic and then taking minimum, its too complicated :/
@AryanAryan-ks5ib
@AryanAryan-ks5ib 8 ай бұрын
Hello sir hello can I get the greedy playlist mujhe mili ni and also can u build the discord server it will be helpful haha
@AryanAryan-ks5ib
@AryanAryan-ks5ib 8 ай бұрын
Edit: sorry I got the playlist bt what about the discord server
@oqant0424
@oqant0424 8 ай бұрын
can anyone explain this part if(k
@codestorywithMIK
@codestorywithMIK 8 ай бұрын
current frequency is freq further in for loop, we will be getting higher frequency because with every loop we are doing freq++ in the for loop. Now, suppose we reach a point where k
@saurabhKumar-hj6yp
@saurabhKumar-hj6yp 8 ай бұрын
❤❤
@shabananoor9423
@shabananoor9423 8 ай бұрын
❤❤
@parththakkar6401
@parththakkar6401 8 ай бұрын
class Solution { public: int findLeastNumOfUniqueInts(vector& arr, int k) { mapmp; for(int i=0;i
@mursalinhawlader6407
@mursalinhawlader6407 8 ай бұрын
class Solution { public: int findLeastNumOfUniqueInts(vector& arr, int k) { mapmp; for(int i=0;isecond); } sort(v.begin(),v.end()); int i=0; while(i=k){ int x=abs(v[i]-k); v[i]=x; k=0; } else{ int x=abs(k-v[i]); k=x; v[i]=0; } i++; } int c=0; for(int i=0;i0)c++; } return c; } };
@manimanohar_001
@manimanohar_001 8 ай бұрын
First view
@dayashankarlakhotia4943
@dayashankarlakhotia4943 8 ай бұрын
public int findLeastNumOfUniqueInts(int[]arr,int k){ Mapmpp=new HashMap(); for(int i:arr) mpp.merge(I,1,Integer::sum); PriorityQueuepq=new PriorityQueue(mpp.values()); while(k>0) k-=pq.poll(); return pq.size()+(k
Bitwise AND of Numbers Range | 2 Approaches | Dry Run | Leetcode 201
34:43
Кәсіпқой бокс | Жәнібек Әлімханұлы - Андрей Михайлович
48:57
Watermelon magic box! #shorts by Leisi Crazy
00:20
Leisi Crazy
Рет қаралды 114 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 454 М.
Viral Video of a Man's Crazy Job Interview
16:02
Darryl Vega TV
Рет қаралды 1,3 МЛН
Best Books for Learning Data Structures and Algorithms
14:01
Engineering with Utsav
Рет қаралды 368 М.
Algorithms Explained for Beginners - How I Wish I Was Taught
17:38
Internet Made Coder
Рет қаралды 355 М.
Map Men vs. Geoguessr
28:07
Jay Foreman
Рет қаралды 802 М.
Ugly Number II | Simple Explanation | Dry Run | codestorywithMIK
31:09
codestorywithMIK
Рет қаралды 14 М.
Number of Subarrays with xor K | Brute - Better - Optimal
24:55
take U forward
Рет қаралды 137 М.
Кәсіпқой бокс | Жәнібек Әлімханұлы - Андрей Михайлович
48:57