Custom Sort String | Hashing Playlist C++ | Leetcode DSA series | Hindi | Complete DSA course
Вставка
- Опубліковано 27 вер 2024
- This is the video under the series of DATA STRUCTURE & ALGORITHM in a HASHING Playlist. We are going to solve the problem "Custom Sort String" from Leetcode which is solved by using a map in c++.
Join My Telegram channel for more Updates: telegram.me/he...
order and str are strings composed of lowercase letters. In order, no letter occurs more than once.
order was sorted in some custom order previously. We want to permute the characters of str so that they match the order that order was sorted. More specifically, if x occurs before y in order, then x should occur before y in the returned string.
Return any permutation of str (as a string) that satisfies this property.
Input:
order = "cba"
str = "abcd"
Output: "cbad"
Explanation: "a", "b", "c" appear in order, so the order of "a", "b", "c" should be "c", "b", and "a".
Since "d" does not appear in order, it can be at any position in the returned string. "dcba", "cdba", "cbda" are also valid outputs.
----------------------------------------------------------------------------------------
Custom Sort String: leetcode.com/p...
code in This Video: github.com/Pri...
Pdf in this video: github.com/Pri...
----------------------------------------------------------------------------------------
*Follow me *
LinkedIn► / iamprince
Facebook► / helloworldofficials
Instagram► / helloworldbyprince
Twitter► / prince_king_
Telegram► telegram.me/he...
----------------------------------------------------------------------------------------
►Our Playlists on:-
►Competitive Programming: • How to start Competiti...
►C++ Full Course : • L-01 || Introduction a...
►Algorithms: • L-01 || Prefix Sum Arr...
►Data Structure: • Data Structures with C...
------------------------------------------------------------------------
🌟 Please leave a LIKE ❤️ and SUBSCRIBE for more AMAZING content! 🌟
✨ Tags ✨
how to Custom Sort String
question asked in Google
how to crack online coding test
how to crack Google Interview
off-campus placement
how to learn to code for beginners
Practice Hashing data structure
hashing in data structure
Best Telegram channel for Off-campus Placement drive
hashing in a data structure in Hindi
unordered_map
#hashing #geeksforgeeks #programming
hashing done .
Bhut Sahi bhai ❤️
nice playlist
I'm glad you like it
Thank you for your guidance
Keep in touch with hello world 🙂
good
Entire playlist was amazing. Please continue making such kind of videos.
Thanks bhai
please keep sharing my videos or channel in your colleges or groups please
Please start Dynamic programming playlist
Haanji
Bhai hashing ki puri playlist dekhne k bad I feel like jukega nhi sala❤️👍🙏
Yeahhhh 🔥 🤩👍👍👍🙂
Main v nahi jukega ab to
1 hi doubt hai meraa baar baar apan log
string s(count,x)
kyu banaa rahe hai ??????????
Kyuki humlog ke pass aisa v case ho sakta hai ki, number of characters repeat hote hai
Please I will recommend u, watch this video again and solve some test case by your own do dry run 🙏
18/18 done (11.12.22)
waoo amazing 👏
Keep making video... 💯🔥
Sure I will 😊
best playlist for hash concepts
Thanks Aritra Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
there is any playlist of bit manipulation ??
still not bro but jaldi hi aa jayega i am sure
mja aagya
bas graph me bhi mujhe aise smj aa jaye toh mauz hai
most waiting for LOTS OF TREE VIDEOS
Bass ab aayega buddy ❤️
Completed brother I'm from Bhurkunda 🤣
Bhahiya ismay unordered_map use kar sakte hai ky hum?
Karke dekho and please send me solution also
Isse bhut aacha lagegaa aapko v and humko v
@@HelloWorldbyprince class Solution {
public:
string customSortString(string order, string s) {
unordered_map umap;
for(auto x:s)
{
umap[x]++;
}
int i,j=0;
string ans;
for(i=0;i!=order.size();i++)
{
char ch=order[i];
auto temp=umap.find(ch);
if(temp!=umap.end())
{
for(j=0;j!=temp->second;j++)
{
ans.push_back(temp->first);
}
}
umap.erase(ch);
}
for(auto x:umap)
{
int c2=x.second;
for(int c=0;c
I have done this at the time of homework
wwwwwwwwwwwwwooooooooho
finally completed the whole hashing series
learnt a hell lot from u
literally thanks bhaiya from the bottom of my heart
please share v kar dena bass thanks
thanks bhai...❤❤❤❤❤
Your welcome buddy 🙂
Good work bhaiya keep it up, please make videos on must-do-questions before interview
Sure yaar
Ye sahi topic hai ...nice 🙂
Completed 👌💯
waooo amazing
Na Na .....pehle waali setup achhi thi
Are bhai, bahut mehant hai ussme, but ab tree most probably pen paper pe padhayenge
My Approach
string customSortString(string order, string str) {
map mp;
string ans = "";
for (auto x : str){
mp[x]++;
}
for (int i=0 ; ifirst;
int val = it->second;
while (val != 0){
ans.push_back(x);
val--;
}
}
return ans;
}
Amazing Pritish
without much stl:
mapmp;
string temp="";
for(auto x:s)mp[x]++;
for(auto x:order){
if(mp.find(x)!=mp.end()){
// order.append(x.second,x.first)
//keep adding till all its freq not bcme 0
while(mp[x]--)temp+=x;//we can add a char in a string (continuation)like this
mp.erase(x);
}
}
//now add rest of the elements from the map into temp;
for(auto x:mp){
while(x.second--)temp+=x.first;
}
return temp;
Good work
Thank you soo much bhaiya
Your welcome buddy, an tree 🌴 ke liye tyaar ho jao
6:03
Yay! Completed hashing series in just 2 days!!! Thanks bde bhai :)
Welcome buddy ❤️
today i have completed your hashing playlist and thanks alot ,i am always afraid about hashing but you make it crystal clear and easy to learn .
Good 😊 work
Keep learning
Waiting for tree playlist😊
Bass ab aane wala hi hai
you are the best.......masum.
bhai, ye jo function s hai, wo built in function hai ki kahi declare kiya hai?
Thank you so much
Nice explanation!
Glad it was helpful!
Thank you Bhaiya
Great video!!
Thanks shamli