Sort Array by Increasing Frequency | Lambda Expression | Hashing | Leetcode DSA series | Hindi

  Рет қаралды 25,588

Hello World

Hello World

Күн бұрын

Пікірлер: 48
@oqant0424
@oqant0424 Жыл бұрын
solved on my own without even looking at the solution......... thanks bhaiya from the bottom of my heart........all credit goes to u your series literally boosted my confidence
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Dil ❤️ se shukriya
@praneshchow
@praneshchow 3 ай бұрын
Thank you vie, Though It looks difficult, your explanation makes it easy.
@maniyadav3256
@maniyadav3256 3 жыл бұрын
teen account se subscibe kiya hu, because you really deserve it ..................
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Waoo thanks for the support buddy
@vishaljain4642
@vishaljain4642 3 жыл бұрын
Gazab Explanation 🔥🔥🔥
@shashwatdev2371
@shashwatdev2371 2 жыл бұрын
By using 2 ordered maps class Solution { public: vector frequencySort(vector& nums) { mapumap; map map_freq; vector final_vec; for(auto a:nums) { umap[a]++;//Saves numbers and their frequency } for(auto k:umap) { map_freq[k.second].push_back(k.first);// map like frequency->(vector containing numbers //having that frequency) } for(auto j:map_freq) { for(int i=j.second.size()-1;i>=0;i--)//reversing vector so that it can be sorted in descending order when frequency is same { for(int l=0;l
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
good work
@pritamsarkar3371
@pritamsarkar3371 3 жыл бұрын
also, you can try hashmap and minheap, which gives same ans with the same complexity
@masumali8356
@masumali8356 Жыл бұрын
you are the best........masum.
@salmaniproductions1104
@salmaniproductions1104 Жыл бұрын
Very well explained. Thank you bhaiyya
@khushipandey6172
@khushipandey6172 Жыл бұрын
Similar problem on gfg gives error of time limit exceeded after passing 119 test case out of 240 . Problem :Sorting element of an array by frequency on gfg Can you provide other more optimized solution?
@vitaminprotein2217
@vitaminprotein2217 2 жыл бұрын
heap sol unordered_mapumap; for(auto x:nums)umap[x]++; priority_queuemaxh; for(auto x:umap){ maxh.push({-x.second,x.first});//- lga ke daal denge usse lest freq wla max bn jyega aur pop krne ke time seedha result aa jyega } vectortemp; while(!maxh.empty()){ //to print acc to freq int freq = maxh.top().first; int element = maxh.top().second; for(int i=1;i
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Amazing yaar
@vishaljain4642
@vishaljain4642 3 жыл бұрын
❤️❤️❤️❤️❤️
@lex-zt6uc
@lex-zt6uc 2 жыл бұрын
thx bhaiya
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
thanks bro
@maniyadav3256
@maniyadav3256 3 жыл бұрын
WHEN THE DAYS ARE SORROW AND NIGHT ARE BITTER, THEN A JOURNEY SEEMS LIKE A BURDEN, DONT LOSS YOUR HOPE , AND KEEP SOME SOAP AS A TOOL TO CLEAN YOUR PATH OF HURDEL.
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
😎😎 Yes
@SemicolonGuy
@SemicolonGuy 3 жыл бұрын
Iski time complexity O (log n) kaise hui?
@Sonukumar-um3cs
@Sonukumar-um3cs 3 жыл бұрын
Sir bahut dino bad video aaya h Tree ke videos thoda jaldi jaldi dalna sir
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Ekdum sure
@rode_atharva
@rode_atharva 5 ай бұрын
/*Example Comparisons During Sorting Initial Vector: nums = {4, 6, 2, 6, 4, 4, 3} Comparator Function: sort(nums.begin(), nums.end(), [&](int a, int b){ return umap[a] != umap[b] ? umap[a] < umap[b] : a > b; }); Comparing 4 and 6: umap[4] = 3 umap[6] = 2 Since umap[4] (3) is not equal to umap[6] (2), compare based on frequency: umap[4] < umap[6] evaluates to 3 < 2 which is false. So, 4 should come after 6. Second Comparison Comparing 6 and 2: umap[6] = 2 umap[2] = 1 Since umap[6] (2) is not equal to umap[2] (1), compare based on frequency: umap[6] < umap[2] evaluates to 2 < 1 which is false. So, 6 should come after 2. Third Comparison Comparing 2 and 6: umap[2] = 1 umap[6] = 2 Since umap[2] (1) is not equal to umap[6] (2), compare based on frequency: umap[2] < umap[6] evaluates to 1 < 2 which is true. So, 2 should come before 6. Fourth Comparison Comparing 6 and 4: umap[6] = 2 umap[4] = 3 Since umap[6] (2) is not equal to umap[4] (3), compare based on frequency: umap[6] < umap[4] evaluates to 2 < 3 which is true. So, 6 should come before 4. Fifth Comparison Comparing 4 and 4: umap[4] = 3 umap[4] = 3 Since umap[4] is equal to umap[4], compare based on value: 4 > 4 evaluates to false. So, the order remains unchanged. Final Sorted Vector After all necessary comparisons(SORT FUNCTION WILL SEE THIS, YOU MY FRIEND DONT CARE OF IT) and swaps, the final sorted vector nums is: {2, 3, 6, 6, 4, 4, 4} Summary of a and b in Comparisons During sorting, a and b are elements from the nums vector that are being compared. The custom comparator checks: If the frequencies of a and b are different (umap[a] != umap[b]), it returns true if a's frequency is less than b's frequency. If the frequencies are the same, it returns true if a is greater than b to ensure that larger elements come first for the same frequency. */
@gauravparasar4571
@gauravparasar4571 4 ай бұрын
costum comparator and lambda fn alg h ?
@starab6901
@starab6901 2 жыл бұрын
In place of lamda function can we use comparator
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
yess
@VaibhavSutar-xm3cn
@VaibhavSutar-xm3cn 4 ай бұрын
var frequencySort = function(nums) { let map = new Map() for(let i=0;ia[1]-b[1]) // console.log(sortedMap) let index = 0 for(let i=0;i0){ sortedMap[i][1] = sortedMap[i][1] -1 nums[index++] = sortedMap[i][0] } } return nums }; solved by own now will watch your tutorial
@samiulislamdurjoy
@samiulislamdurjoy 3 жыл бұрын
7:22
@ogbuddha7835
@ogbuddha7835 2 жыл бұрын
Jun 19 2022, results are out of 6th sem yesterday. Placements are coming. Ask me after 1 year how am i and where am i
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Pakaa promise I will ask
@shubhambhatt2704
@shubhambhatt2704 Жыл бұрын
@OGBuddhA Ha Bhai kidhar hai?
@ogbuddha7835
@ogbuddha7835 Жыл бұрын
@@shubhambhatt2704 placed in an international company. Good package 11lpa
@oqant0424
@oqant0424 Жыл бұрын
17/18 done (11.12.22)
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
good
@satyamsrivastava1871
@satyamsrivastava1871 2 жыл бұрын
bhaiya maine asa socha pr problem aa rha class Solution { public: vector frequencySort(vector& nums) { vector ans; unordered_map um; for(auto x:nums) { um[x]++; } set s; for(auto x:um) { auto temp=x.second; s[temp]++; } for(auto x:s) { ans.push_back(x); } return ans; } };
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
kya problem aa rha dry run karo koi ek example lekar samjh me aa jayega ki kya gaklti ho rha hai
@vishaljain4642
@vishaljain4642 3 жыл бұрын
Bhaiya graph ki series kab ane wali he??
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Tree ke baad Tree ke baad maximum confidence aa jayega
@divyansh1391
@divyansh1391 2 жыл бұрын
bhaiya apne bass code kr diya hai...vhi to samjna hai vhi nhi btaye aap
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
I will request u to please watch hashing playlist from starting buddy
@praveenanand5689
@praveenanand5689 2 жыл бұрын
how to solve this problem without using lambda function
@hrithikraj6587
@hrithikraj6587 2 жыл бұрын
Also in java??
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
sure but it will take some time
@udaymishra5916
@udaymishra5916 3 жыл бұрын
Yaha ye kaise determine hua ki a is greater than b hi hai???
@HelloWorldbyprince
@HelloWorldbyprince 3 жыл бұрын
Maine kaha tha, lambda function me ye maan ke chal rahe hai ki a pahle aayega b se
@KaifKhan-PizzaAndcode
@KaifKhan-PizzaAndcode 2 жыл бұрын
Bhaiya return wali line ek bar bta do smjh ni ayi Please Please Pleaseeeeeeeeeeeeeeeee.........
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
kya nhi samjha ussme aap ye batao ek baar please Hashing starting se dekho aap please and ek baar dry run v karo mere code ko its your homework
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 24 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,7 МЛН
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН
Sort Characters By Frequency | Sorting | Lambda | Leetcode 451
17:24
codestorywithMIK
Рет қаралды 9 М.
⚡️NEWS | RUBLE COLLAPSE | STRIKE ON CRIMEA | PUTIN IN KAZAKHSTAN
10:34
Ходорковский LIVE
Рет қаралды 204 М.
Sort Array by Increasing Frequency - Leetcode 1636 - Python
8:17
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН