일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 개발자
- 방송통신대학교
- 위니펙
- 컴퓨터과학과
- LAA
- mpnp
- Deep learning
- 기본
- 프로그래머스
- 캐나다 영주권
- leetcode
- EOI
- MATLAB
- 방통대
- C++
- 선형대수
- cpp
- 딥러닝
- 코딩테스트
- machine learning
- LV1
- 머신러닝
- omscs
- Plotting
- 온라인석사
- 주정부이민
- 매트랩
- 알고리즘
- zeros
- 조지아텍
Archives
- Today
- Total
Byte by Byte
49. Group Anagrams.cpp 본문
🔑 map의 두번째 인자에 vector container도 삽입 가능!
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
vector<vector<string>>res;
map<string,vector<string>>m;
for(auto &s : strs) {
string tmp = s;
sort(tmp.begin(),tmp.end());
m[tmp].push_back(s);
}
for(auto sub : m) {
//cout<< s << endl;
res.push_back(sub.second);
}
return res;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
442. Find All Duplicates in an Array.cpp (0) | 2022.01.24 |
---|---|
1854. Maximum Population Year.cpp (0) | 2021.12.17 |
1078. Occurrences After Bigram.cpp (0) | 2021.12.15 |
1598. Crawler Log Folder.cpp (0) | 2021.12.15 |
1694. Reformat Phone Number.cpp (0) | 2021.12.15 |