Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- RBAC
- asyncio
- POD
- AZURE
- AZ-104
- Django
- FastAPI
- docker
- EKS
- elasticsearch
- ebs
- Service
- K8S
- AWS
- terraform
- EC2
- Python
- Deployment
- ansible
- AZ-900
- asgi
- IAM
- 자바스크립트
- IAC
- Role
- Network
- Kubernetes
- DevOps
- dockerfile
- leetcode
Archives
- Today
- Total
궁금한게 많은 개발자 노트
[ leetcode ] 49. Group Anagrams 본문
string의 배열이 들어왔을 때, anagram 단어들을 grouping하여 반환하는 문제입니다.
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
#include<algorithm>
#include<unordered_map>
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
unordered_map<string, vector<string>> hash_table;
for (int i = 0; i < strs.size(); i++){
string temp = strs[i];
sort(temp.begin(), temp.end());
hash_table[temp].push_back(strs[i]);
}
vector<vector<string>> answer;
for (pair<string, vector<string>> item : hash_table)
answer.push_back(item.second);
return answer;
}
};
Comments