Notice
Recent Posts
Recent Comments
- Today
- Total
01-10 22:06
Tags
- PS
- dp
- database
- OOP
- ๋ฐฑ์ค
- ๋ฒจ๋งํฌ๋
- MST
- BFS
- spring
- tree
- ์ธํด
- Algorithm
- Graph
- ๋ฐฑ์๋
- ๋ฌธ๋ฒ
- ์๋ฐ์์ ์
- ์๋ฃ๊ตฌ์กฐ
- CS
- ์กธ์ ์ํ
- array
- ์์์ ๋ ฌ
- ๊ตฌํ
- ํ๋ก๊ทธ๋๋จธ์ค
- java
- ์๋ฐ
- ๊ทธ๋ฆฌ๋
- pytorch
- leetcode
- ๋ค์ต์คํธ๋ผ
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
Link
Partially Committed
[2019 KAKAO BLIND RECRUITMENT] ์คํ์ฑํ ๋ฐฉ ๋ณธ๋ฌธ
๐ฅ Algorithm || ๋ฌธ์ ํ์ด/PS
[2019 KAKAO BLIND RECRUITMENT] ์คํ์ฑํ ๋ฐฉ
WonderJay 2022. 7. 7. 11:19728x90
๋ฐ์ํ
SMALL
https://school.programmers.co.kr/learn/courses/30/lessons/42888
[C++]
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <iostream>
using namespace std;
vector<string> solution(vector<string> record) {
vector<string> answer;
map<string, string> user_list;
vector<string> log;
vector<string> tok(3, "");
vector<string> id_list;
string enter_mes = "๋์ด ๋ค์ด์์ต๋๋ค.";
string leave_mes = "๋์ด ๋๊ฐ์ต๋๋ค.";
for(int i = 0 ; i < record.size(); i ++)
{
istringstream ss(record[i]);
string buf = "";
int k = 0;
while(ss >> buf) tok[k++] = buf;
if(tok[0] == "Enter")
{
user_list[tok[1]] = tok[2];
id_list.push_back(tok[1]);
log.push_back(enter_mes);
}
if(tok[0] == "Leave")
{
user_list.insert(make_pair(tok[1], user_list[tok[1]])); // insert id,name
id_list.push_back(tok[1]);
log.push_back(leave_mes);
}
if(tok[0] == "Change")
{
user_list[tok[1]] = tok[2];
}
}
for(int i = 0 ; i < log.size(); i++)
answer.push_back(user_list[id_list[i]] + log[i]);
return answer;
}
728x90
๋ฐ์ํ
LIST
'๐ฅ Algorithm || ๋ฌธ์ ํ์ด > PS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ์ ํ๋ฒํธ ๋ชฉ๋ก (0) | 2022.07.08 |
---|---|
[2020 KAKAO BLIND RECRUITMENT] ๊ดํธ ๋ณํ (0) | 2022.07.08 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ด์ํ ๋ฌธ์ ๋ง๋ค๊ธฐ (0) | 2022.07.06 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์์ ์ฐพ๊ธฐ (0) | 2022.07.06 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฌธ์์ด ๋ด ๋ง์๋๋ก ์ ๋ ฌํ๊ธฐ (0) | 2022.07.06 |
Comments