Notice
Recent Posts
Recent Comments
Link
Tags
- ํธ๋ฆฌ
- ๊ฐ์ฅ๊ฐ๊น์ด๊ณตํต์กฐ์
- ์๊ณ ๋ฆฌ์ฆ
- ์ํฐ๋
- ๋นํธ๋ง์คํน
- ๋์ ํ๋ก๊ทธ๋๋ฐ
- DP
- ์ฌ๊ท
- js
- ์์ฝ๋
- ์นด์นด์ค ์ฝํ
- Union-Find
- ํ๋ก๊ทธ๋๋จธ์ค
- Python
- C++
- go
- ํ๋ฆฌ์จ๋ณด๋ฉ
- ๋ฐฑ์ค
- BFS
- LCs
- ์ด๋ถํ์
- ๋นํธ๋งต
- ์ฌ๋ผ์ด๋ฉ ์๋์ฐ
- ๋ฐฑ์๋ ํ๋ฆฌ์จ๋ณด๋ฉ
- golang
- ์น๋ฆฐ์ด
- ๋ค์ต์คํธ๋ผ
- DFS
- nestjs
- ์นด์นด์ค2021
Archives
- Today
- Total
Hello Ocean! ๐ผ
[ํ๋ก๊ทธ๋๋จธ์ค/์นด์นด์ค ์ฝํ ] ์คํ์ฑํ ๋ฐฉ ๋ณธ๋ฌธ
๋ฐ์ํ
ver 1
#include <string>
#include <vector>
#include<sstream>
#include<map>
using namespace std;
vector<string> solution(vector<string> record) {
vector<string> answer;
map<string, string> dict;
for (int i = 0;i < record.size();i++) {
vector<string> splited;
istringstream temp(record[i]);
string stringBuffer;
while (getline(temp, stringBuffer, ' '))
{
splited.push_back(stringBuffer);
}
if (splited[0] == "Enter" || splited[0] == "Change")
dict[splited[1]] = splited[2];
}
for (int i = 0;i < record.size();i++) {
vector<string> splited;
istringstream temp(record[i]);
string stringBuffer;
while (getline(temp, stringBuffer, ' '))
{
splited.push_back(stringBuffer);
}
string ans;
if (splited[0] == "Enter") {
ans = dict[splited[1]] + "๋์ด ๋ค์ด์์ต๋๋ค.";
answer.push_back(ans);
}
else if (splited[0] == "Leave") {
ans = dict[splited[1]] + "๋์ด ๋๊ฐ์ต๋๋ค.";
answer.push_back(ans);
}
}
return answer;
}
ํ ์คํธ 1 ใ | ํต๊ณผ (0.05ms, 3.89MB) |
ํ ์คํธ 2 ใ | ํต๊ณผ (0.04ms, 3.95MB) |
ํ ์คํธ 3 ใ | ํต๊ณผ (0.11ms, 3.82MB) |
ํ ์คํธ 4 ใ | ํต๊ณผ (0.13ms, 3.93MB) |
ํ ์คํธ 5 ใ | ํต๊ณผ (1.53ms, 3.94MB) |
ํ ์คํธ 6 ใ | ํต๊ณผ (1.73ms, 3.96MB) |
ํ ์คํธ 7 ใ | ํต๊ณผ (1.39ms, 3.93MB) |
ํ ์คํธ 8 ใ | ํต๊ณผ (1.67ms, 3.93MB) |
ํ ์คํธ 9 ใ | ํต๊ณผ (2.02ms, 3.93MB) |
ํ ์คํธ 10 ใ | ํต๊ณผ (1.72ms, 3.95MB) |
ํ ์คํธ 11 ใ | ํต๊ณผ (1.05ms, 3.95MB) |
ํ ์คํธ 12 ใ | ํต๊ณผ (1.03ms, 3.89MB) |
ํ ์คํธ 13 ใ | ํต๊ณผ (1.67ms, 3.91MB) |
ํ ์คํธ 14 ใ | ํต๊ณผ (2.02ms, 4.01MB) |
ํ ์คํธ 15 ใ | ํต๊ณผ (0.05ms, 3.97MB) |
ํ ์คํธ 16 ใ | ํต๊ณผ (0.04ms, 3.93MB) |
ํ ์คํธ 17 ใ | ํต๊ณผ (0.20ms, 3.97MB) |
ํ ์คํธ 18 ใ | ํต๊ณผ (0.21ms, 3.93MB) |
ํ ์คํธ 19 ใ | ํต๊ณผ (1.72ms, 4.11MB) |
ํ ์คํธ 20 ใ | ํต๊ณผ (1.49ms, 3.91MB) |
ํ ์คํธ 21 ใ | ํต๊ณผ (1.51ms, 3.96MB) |
ํ ์คํธ 22 ใ | ํต๊ณผ (1.53ms, 3.98MB) |
ํ ์คํธ 23 ใ | ํต๊ณผ (1.78ms, 4.04MB) |
ํ ์คํธ 24 ใ | ํต๊ณผ (1.83ms, 4MB) |
ํ ์คํธ 25 ใ | ํต๊ณผ (190.21ms, 41.7MB) |
ํ ์คํธ 26 ใ | ํต๊ณผ (216.32ms, 39.9MB) |
ํ ์คํธ 27 ใ | ํต๊ณผ (231.34ms, 41.4MB) |
ํ ์คํธ 28 ใ | ํต๊ณผ (250.06ms, 46.4MB) |
ํ ์คํธ 29 ใ | ํต๊ณผ (252.67ms, 46.3MB) |
ํ ์คํธ 30 ใ | ํต๊ณผ (184.68ms, 39.4MB) |
ํ ์คํธ 31 ใ | ํต๊ณผ (208.18ms, 40.6MB) |
ํ ์คํธ 32 ใ | ํต๊ณผ (167.06ms, 38.2MB) |
ver 2
#include <string>
#include <vector>
#include<sstream>
#include<map>
using namespace std;
vector<string> solution(vector<string> record) {
vector<string> answer;
vector<vector<string>> data;
map<string, string> dict;
for (int i = 0;i < record.size();i++) {
vector<string> splited;
istringstream temp(record[i]);
string stringBuffer;
while (getline(temp, stringBuffer, ' '))
{
splited.push_back(stringBuffer);
}
if (splited[0] == "Enter" || splited[0] == "Change")
dict[splited[1]] = splited[2];
if (splited[0] == "Enter" || splited[0] == "Leave") {
vector<string> row = { splited[0],splited[1] };
data.push_back(row);
}
}
for (int i = 0;i < data.size();i++) {
vector<string> row = data[i];
string ans;
if (row[0] == "Enter") {
ans = dict[row[1]]+"๋์ด ๋ค์ด์์ต๋๋ค.";
answer.push_back(ans);
}
else if (row[0] == "Leave") {
ans = dict[row[1]] + "๋์ด ๋๊ฐ์ต๋๋ค.";
answer.push_back(ans);
}
}
return answer;
}
ํ ์คํธ 1 ใ | ํต๊ณผ (0.04ms, 3.96MB) |
ํ ์คํธ 2 ใ | ํต๊ณผ (0.05ms, 3.93MB) |
ํ ์คํธ 3 ใ | ํต๊ณผ (0.10ms, 3.93MB) |
ํ ์คํธ 4 ใ | ํต๊ณผ (0.10ms, 3.94MB) |
ํ ์คํธ 5 ใ | ํต๊ณผ (1.09ms, 3.97MB) |
ํ ์คํธ 6 ใ | ํต๊ณผ (1.24ms, 4.07MB) |
ํ ์คํธ 7 ใ | ํต๊ณผ (1.03ms, 3.93MB) |
ํ ์คํธ 8 ใ | ํต๊ณผ (1.23ms, 3.95MB) |
ํ ์คํธ 9 ใ | ํต๊ณผ (1.67ms, 4.19MB) |
ํ ์คํธ 10 ใ | ํต๊ณผ (1.33ms, 3.94MB) |
ํ ์คํธ 11 ใ | ํต๊ณผ (0.82ms, 3.94MB) |
ํ ์คํธ 12 ใ | ํต๊ณผ (0.82ms, 3.94MB) |
ํ ์คํธ 13 ใ | ํต๊ณผ (1.24ms, 3.94MB) |
ํ ์คํธ 14 ใ | ํต๊ณผ (1.57ms, 4MB) |
ํ ์คํธ 15 ใ | ํต๊ณผ (0.04ms, 3.93MB) |
ํ ์คํธ 16 ใ | ํต๊ณผ (0.04ms, 3.93MB) |
ํ ์คํธ 17 ใ | ํต๊ณผ (0.17ms, 3.94MB) |
ํ ์คํธ 18 ใ | ํต๊ณผ (0.15ms, 3.94MB) |
ํ ์คํธ 19 ใ | ํต๊ณผ (1.42ms, 3.97MB) |
ํ ์คํธ 20 ใ | ํต๊ณผ (1.03ms, 3.93MB) |
ํ ์คํธ 21 ใ | ํต๊ณผ (1.03ms, 3.95MB) |
ํ ์คํธ 22 ใ | ํต๊ณผ (1.10ms, 3.93MB) |
ํ ์คํธ 23 ใ | ํต๊ณผ (1.28ms, 4.01MB) |
ํ ์คํธ 24 ใ | ํต๊ณผ (1.37ms, 4.09MB) |
ํ ์คํธ 25 ใ | ํต๊ณผ (161.58ms, 47.2MB) |
ํ ์คํธ 26 ใ | ํต๊ณผ (190.26ms, 49.9MB) |
ํ ์คํธ 27 ใ | ํต๊ณผ (208.04ms, 52.3MB) |
ํ ์คํธ 28 ใ | ํต๊ณผ (219.66ms, 53.8MB) |
ํ ์คํธ 29 ใ | ํต๊ณผ (210.52ms, 53.8MB) |
ํ ์คํธ 30 ใ | ํต๊ณผ (154.95ms, 42.4MB) |
ํ ์คํธ 31 ใ | ํต๊ณผ (187.32ms, 50.7MB) |
ํ ์คํธ 32 ใ | ํต๊ณผ (144.40ms, 45.3MB) |
๋ฐ์ํ
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค/C++] ํฌ๋ ์ธ ์ธํ๋ฝ๊ธฐ ๊ฒ์ (0) | 2020.12.29 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฑ๊ตฃ๊ธธ (0) | 2020.12.28 |
[ํ๋ก๊ทธ๋๋จธ์ค] 2020 ์นด์นด์ค/๊ดํธ ๋ณํ (0) | 2020.10.12 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฌธ์์ด ์์ถ (0) | 2020.10.05 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ฌํ ๊ฒฝ๋ก, C++ (0) | 2020.09.21 |