Sarvar shares – Telegram
Sarvar shares
3 subscribers
2 photos
2 videos
1 file
11 links
Download Telegram
Channel created
بِسْمِ ٱللّٰهِ ٱلرَّحْمٰن ٱلرَّحِيمِ
LeetCode dagi bugungi kun 49. Group Anagrams masalasiga simple yechim
class Solution {
public:
string hash(string s){

string res('*',29);
for(char c:s)
res[c-97]++;
return res;
}

vector<vector<string>> groupAnagrams(vector<string>& strs) {
vector<vector<string>> res;

unordered_map<string,vector<string>> mp;
for(int i=0;i<strs.size();i++){
mp[hash(strs[i])].push_back(strs[i]);
}
for(auto v:mp)
res.push_back(v.second);
return res;
}
};
Yodda tuting linq so'rovlar kechiktiriladi, ya'ni siz result uchun so'rov(query) yozganizda emas result ga murojaat qilganizda ishga tushadi.

#tips #linq
Forwarded from Programmer Humor
[Meme] learnDontRelyOnAI
https://redd.it/1fmtjo9

by @programmer_humor