Sort Characters By Frequency | Sorting | Lambda | Leetcode 451

  Рет қаралды 10,500

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 51
@naturevinu7886
@naturevinu7886 11 ай бұрын
aap jo story batate ho to lagta he bhai coding to me bhi kar sakta hu or bahot had tar to problme khud hi solve kar pata hu love you sir
@aws_handles
@aws_handles 11 ай бұрын
I get relaxed when I see you already have a video on youtube for a problem.
@amanisdreaming3914
@amanisdreaming3914 9 ай бұрын
lol same
@aninima01
@aninima01 3 ай бұрын
same xD
@AdityaSharma-sf1yh
@AdityaSharma-sf1yh Жыл бұрын
You are genius, you don't know but you have explained it perfectly and far better than other KZbin tutors. Thank you so much!
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Means a lot to me. Thank you so much 🙏😇
@FanIQQuiz
@FanIQQuiz 11 ай бұрын
💯
@rachitaa._
@rachitaa._ 26 күн бұрын
Solved this using priority queue somehow(like solving a puzzle) , but still couldn't get how it was working, came here to actually know . I knew I would be satisfied with only your explanation of the question.
@hrithikrudra4292
@hrithikrudra4292 2 жыл бұрын
Amazing brother....Keep uploading such wow content..
@codestorywithMIK
@codestorywithMIK 2 жыл бұрын
Thanks a lot Hrithik ❤️❤️❤️
@udaytewary3809
@udaytewary3809 2 жыл бұрын
Really thankyou bhaiya for making it so easy to understand and also learn new things about comparator from you
@codestorywithMIK
@codestorywithMIK 2 жыл бұрын
I am so glad to hear that Uday ❤️❤️❤️
@priyamittal8302
@priyamittal8302 10 ай бұрын
Finally understood this concept. thanks a lot!
@Ankitkumar-fz3kc
@Ankitkumar-fz3kc 11 ай бұрын
Thanks, I solved it by myself still came here to learn something new and learnt something thanks.
@codestorywithMIK
@codestorywithMIK 11 ай бұрын
So glad to know ❤️❤️🙏🙏 Always note down the things which you are learning in a note book, or note it down somewhere so that you can revisit them later
@Ankitkumar-fz3kc
@Ankitkumar-fz3kc 11 ай бұрын
@@codestorywithMIK sir how to take notes and how to revise can you please share some insight regarding this.
@FifthArima
@FifthArima 11 ай бұрын
@@Ankitkumar-fz3kc had the same doubt. @codestorywithmik pls share your inputs
@codestorywithMIK
@codestorywithMIK 11 ай бұрын
For taking notes, What I did was note the important points on a Notebook earlier. But I wanted to access it anywhere so I started to make notes online (google doc etc) so that I can access it online from anywhere. Make. Google doc dedicated to every topic and keep the notes in those. Keep revisiting them time to time
@souravjoshi2293
@souravjoshi2293 2 жыл бұрын
Thanks a lot man. simple and crystal clear
@souradeepghosh9888
@souradeepghosh9888 11 ай бұрын
Nice explanation bhaiya
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
Keep uploading such amazing contents.
@saumyasrivastava5390
@saumyasrivastava5390 2 жыл бұрын
Please upload the PQ solution as well. I implemented this but I am unable to think in that direction
@souravjoshi2293
@souravjoshi2293 2 жыл бұрын
Me too. It would be great to have a PQ solution as well for this from you @Interview_DS_Algo Thanks in advance
@codestorywithMIK
@codestorywithMIK 2 жыл бұрын
Sure. I am on it. Give me sometime. I will upload it today only. Thanks again for your question and watching my videos
@codestorywithMIK
@codestorywithMIK 2 жыл бұрын
Uploaded the Heap(PQ) approach Link :kzbin.info/www/bejne/fqimipRnlJepobc
@aws_handles
@aws_handles 11 ай бұрын
Thanks a lot@@codestorywithMIK
@FanIQQuiz
@FanIQQuiz 11 ай бұрын
@@codestorywithMIK I was looking for this. Thank you
@theOmKumar
@theOmKumar 11 ай бұрын
I solved it like this. string frequencySort(string s) { string ans; int freq[128] = {0}; for(int i = 0; i < s.size(); i++){ freq[s[i]]++; } map m; for(int i = 0; i < 128; i++){ m[ freq[i] ] += string(freq[i], (char)i); } for(auto it = m.rbegin(); it != m.rend(); it++){ ans += it->second; } return ans; }
@divyanshualiwal
@divyanshualiwal 5 ай бұрын
Awsm explanation !
@varunsheth1003
@varunsheth1003 2 жыл бұрын
Amazing brother...
@codestorywithMIK
@codestorywithMIK 2 жыл бұрын
Thanks a lot Varun ❤️❤️❤️
@gauravbanerjee2898
@gauravbanerjee2898 11 ай бұрын
Thanks a lot bhaiya ❤❤
@ShubhiSrivastava-dc6zk
@ShubhiSrivastava-dc6zk Жыл бұрын
is code ki space complexity or time complexity explain kr dijiye plz plz
@DevOpskagyaan
@DevOpskagyaan 11 ай бұрын
Done ❤️
@rajeevkumarsingh8719
@rajeevkumarsingh8719 2 жыл бұрын
i m confused that how the pair get stored in vector can anyone help. line 9-11
@codestorywithMIK
@codestorywithMIK 2 жыл бұрын
Hi Rajeev, let's look at an example to understand this. Suppose we have example : "tree" Now let's populate : vector vec; i = 0, 't', we don't have 't' populated in vector as of now. vec = { {'t', 1}} i = 1, 'r', we don't have 'r' populated in vector as of now. vec = { {'t', 1}, {'r', 1}} i = 2, 'e', we don't have 'e' populated in vector as of now. vec = { {'t', 1}, {'r', 1}, {'e', 1}} Now, for i = 3, 'e', we already have {'e', 1} in our vector So, take out frequency of 'e' already present in vector : i.e. freq = 1 int freq = 1 Now, we add 1 more to it, because we have got another 'e' at index = 3 and then insert it back to vec (updated value) vec = { {'t', 1}, {'r', 1}, {'e', 2}} Hope I was able to clear now. Thank you for watching
@rajeevkumarsingh8719
@rajeevkumarsingh8719 2 жыл бұрын
Yeah very helpful
@codestorywithMIK
@codestorywithMIK 2 жыл бұрын
Glad to know that Rajeev. Thanks
@factshubonly
@factshubonly 11 ай бұрын
ordered map already sorted hota hai usse nhi kar sakte kya?
@codingwithsukesh
@codingwithsukesh 23 күн бұрын
Github pe java code bhi upload kro sir
@kumarashutosh-p3n
@kumarashutosh-p3n 8 ай бұрын
unordered_mapm; for(auto x:s) m[x]++; sort(begin(s),end(s),[&](char a, char b){ return m[a]!=m[b]?m[a]>m[b]:a
@VinayKumar-vm1hg
@VinayKumar-vm1hg 11 ай бұрын
vec[ch] or we have to take index
@dayashankarlakhotia4943
@dayashankarlakhotia4943 11 ай бұрын
class Solution { public String frequencySort(String str){ char[]s=str.toCharArray(); int[]freq=new int[128]; for(int i=0;i
@xboy2374
@xboy2374 11 ай бұрын
bhaiua run time error aa rhaa 32 test case mai se 29 chle
@codestorywithMIK
@codestorywithMIK 11 ай бұрын
My code seems to be working fine. Can you share your code ?
@prathamdhiman7071
@prathamdhiman7071 11 ай бұрын
Sir can you also code in java
@tech_funda_official
@tech_funda_official 8 ай бұрын
is solution me kya problem h? class Solution { public: string frequencySort(string s) { typedef pair P; vector arr(122); for (char& i : s) { int freq = arr[i].second; arr[i] = {i, freq + 1}; } auto lambda = [&](P &p1, P &p2) { return p1.second > p2.second; }; sort(arr.begin(), arr.end(), lambda); string ans = ""; for (int i = 0; i
@harshkumar4047
@harshkumar4047 5 ай бұрын
Mention in the video title only for C++ language, bcz Java valo ko toh kuch samjh hi nhi aya.
@harshasshet6755
@harshasshet6755 4 ай бұрын
bro concept to same hai just language is diferent learn concept and for code ask chatgpt and all fine
@harshkumar4047
@harshkumar4047 4 ай бұрын
@@harshasshet6755 Beta 9:00 minute se jo isne bataya hai voh code based hai (C++ language specific), isme conceptual kuch nhi hai. Real conceptual videos irrespective of lang. dekhne hai toh jaa kr Striver dekh munna.
Sort Characters By Frequency | Heap | Leetcode 451
16:53
codestorywithMIK
Рет қаралды 7 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Sort Characters By Frequency - Leetcode 451 - Python
10:57
NeetCodeIO
Рет қаралды 20 М.
String to Integer atoi 🔥| Leetcode 8 | String
16:59
Ayushi Sharma
Рет қаралды 50 М.
Every Sorting Algorithm Explained in 120 minutes (full series)
1:57:33
Kuvina Saydaki
Рет қаралды 82 М.
4 Sum | Brute - Better - Optimal with Codes
28:47
take U forward
Рет қаралды 208 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН