Group Anagrams | Print Anagrams Together | Hashing | Leetcode DSA series | Hindi
Вставка
- Опубліковано 27 вер 2024
- This is the video under the series of DATA STRUCTURE & ALGORITHM in a HASHING Playlist. We are going to solve the problem "Group Anagrams" from Leetcode which is solved by using a vector, map in c++.
Join My Telegram channel for more Updates: telegram.me/he...
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
----------------------------------------------------------------------------------------
Group Anagrams: leetcode.com/p...
Print Anagrams Together: practice.geeks...
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 solve Print Anagrams Together
how to solve 49. Group Anagrams
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
this is the only course on youtube which cover whole hashing in very simple way
thanks for this amazing playlist ❤
thank you prince bhai video abhi pura nai dekha pr starting m aap ne voh baat keh dii ki logic dimag m aajata h pr implement nai hota toh yeh bhout hota h mere sth .
This question irritates a lot but now thank you for this solution!!!!
Mujhe v irritate karta tha ye question 😁
Your Teaching style is good because you work on real problem like leetcode and gfg problems
Bhaiyya app ki explanation gazab he🔥🔥🔥🔥🔥
Thanks vishal
Thankfully say to increase my interest in coding skill and understanding of problem...🙏🙏🙏💕💕💕
yeah i did it ❤
Am actually following this series since yesterday. Almost done with it.
Also, I tried solving the problems on my own, first.
Thanks alot!
bro, vo string ko sort karne ke bat kya equal no of char ke respect me key val store ho raha hai kay ???
@@PIYUSH-lz1zq ha, uss sort string ke andr wli value ke corresponding original string ko map kra rhe,
also can u tell me why we use x.second insted x->second ?as i didnt understant from the video
Well done! Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
Understandable and quick solution......👌👌
Thanks buddy ❤️
thank you so much sir u r real good teacher..u exp very well
You are most welcome
Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
Hey man can you explain the more optimized approach of this question without sorting
Bhaiya thankyou finally Hashing ke problem ab solve ho rhe hai🥰
Bass please yaar share kardo channel ko
class Solution {
public:
vector groupAnagrams(vector& strs) {
vector ans;
map mp;
for(auto i :strs){
string key = i;
sort(key.begin(), key.end());
mp[key].push_back(i);
}
for(auto i :mp){
ans.push_back(i.second);
}
return ans;
}
};
U made a tough question ,so easy!
Thanks yaar
Amazing sir grate explanation!! but I would like to add one suggestion it would be more efficient if you use (auto &x:strs) as passing by reference wont create copies of the same variables as it might be expensive in case of strings. Keep the good work up sir👍👍👍
okay sure i will do that
Great video nice explanation.
Glad you liked it!
great tutor
Waaoo chidambar Thanks a lot
explanation is easy
Hello Prince Bhaiya,
ek help chahiye thi
subarrray O(n) me solve krna hai.
But ham isko O(n^3) me hi kr pa rhai hai
Plz help because I search every where but not find answer
Bhaiya kuch solution batai iska
Use kadane's algorithms which is used for solving subarray in O(n )time search in UA-cam 😀
@@shivamehta6537 bhai ye sayad sum max ke lia hoti hai may be dekhta hu
subarray me kya karna hai ? pahle aap ye clear karo
@@HelloWorldbyprince bhaiya
generate all possible subarray of given array
bro tell one thing i used map as unordered_map will not hash vector and map by default, but when i am trying to do find of vector its saying no matching call. whats it
vector groupAnagrams(vector& strs) {
map mpp;
vector ans;
for(auto s : strs){
vector count(26,0);
for(char ch : s){
count[ch-'a']++;
}
}
if(mpp.find(count) != mpp.end()){
mpp[count].push_back(s);
}else{
mpp[count].push_back(s);
}
for(auto it : mpp){
auto temp = it.second;
ans.push_back(temp);
}
return temp;
}
u never disappoint anyone...Gained a like share and a subscriber
🤩🤩
very neat and easy explanation. Thanks sir !
You are welcome
Thanks bro! You solution was very easy to understand and uncomplicated. 🔥
*One word that comes out from my mouth after watching your video is* -Sekc-
yeah 🔥
Perfect Explanation!
Thank you bhaiya
great explanation prince bhaiya keep it up
Thanks for the support soheb
Thanks bhai for easy method
bro, vo string ko sort karne ke bat kya equal no of char ke respect me key val store ho raha hai kay ???
Any time
Thank you sir for awesome explanation.
You are most welcome
Thanks a lot sir!!! :)
keep learning bro
✨👍🏻
when i first saw your video , i am sorry but i thought i should watch some other video as it was very dark themed XD , but bro your explanation is so good that if i see your face in a video i am searching i know you will make me understand that concept top to bottom.
Thanks 😅
@@HelloWorldbyprince I finished hashing , data structure playlist .😁
Bhaiyya graph ke upar videos banao
great!!
DONE! Thank you bhaiiyyaa
great work
keep learning buddy and be consistent and share my channel with your college groups that helps me a lot
that's good.
Thanks a ton buddy
keep making video bro
sure
16/18 done (11.12.22)
keep learning buddy
Bhaiya....Kisi BHI code Ka time and space complexity kaise. Calculate krte hai....ispr video bna dijiye
ekdum sure buddy
do explain time and space complexities please
TC: O(1) as unordered map require O(1) for its operation
SC: O(n^2) b/c of using 2d ans array to store ans
i got an intution of taking map and sorting each and every element and comparing it but still i was not confident
i hope ab samjh me aa gya hoga
Khud se aise solve kiya lekin time limit exceed ho gaya 😂😂
class Solution {
bool isAnagram(string s, string r){
sort(s.begin(),s.end());
sort(r.begin(),r.end());
if(r==s){
return true;
}
return false;
}
public:
vector groupAnagrams(vector& strs) {
vector ans;
vector mark(size,0);
int size = strs.size();
for(int i=0;i
Koi baat nahi yaar
This is part of learning 🤓
lmao dude you made it so easy
Thanks a lot
Noice
Thanksssssss
Time and space complexity??
I have done with logic for earlier question and it was as similar as your logic but the trouble was implementation with code
Thankyou very much
Hey Prince 👋
Graph samz ne me dikkat aa rhi he
will upload soon buddy
ya sir ho gaya
🤩🤩
bro, vo string ko sort karne ke bat kya equal no of char ke respect me key val store ho raha hai kay ???
🔥
please make a series on dynamic programming
Yeah yogesh sure
Coding made easy from the moment I got to know about this channel
Hahah Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
your explantion is amazing
Thanks
Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
only video with 0 dislikes ...great going bhaiya
It's all the support of you guys
Very good problem and well explained!!
Thanks bhaiya!!!!!
Thanks bhai
Bass share kardo channel ko mere motivation ke liye
@@HelloWorldbyprince I shared ur video with my frnds
Sir ab aap popular ho
hahah
Nice explanation...keep it up😊
Thanks a ton
Please, if possible then share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
man ur explaination is the best
Thanks Yogesh
Easy explanation
Keep it up!!
Just wanna thank you for explaining so well.
You are doing great sakshi
Keep learning 😃
🙈
🤩🤩
you are the best........masum.
Homework completed!! 🕑
bhai linked list par bhi banaao yaar
please increase Font Size of code section.
Sir the solution is way too good but I think we should sort temp and insert x , because we should not change the given data set.
we are not changing given data set , when u do auto x:strs, copy of every element of strs will get stored in x for each iteration... its not the original element , its the copy.
Hat's off bhaiya, really apke explain krne ka trika amazing hai, aap aisa padhate hai ki concept chhap jata hai dimak me. Thanks alot bhaiya for such a amzing playlist.
Thanks 😊
Really liked the explanation + code ❤
Glad to hear that!
Bohot sahi bhiya....Aap actully man ki baat jaan lete hai😃
Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
Great video series 👍 👏 👌
Thanks 👍
Great solution man