Skip to content

Commit

Permalink
이슈 #372에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 21, 2024
1 parent f362672 commit a39cef8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Programmers/영어가_싫어요.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

long long solution(string numbers) {
long long answer = 0;
unordered_map<string, int> m = {
{"zero", 0},
{"one", 1},
{"two", 2},
{"three", 3},
{"four", 4},
{"five", 5},
{"six", 6},
{"seven", 7},
{"eight", 8},
{"nine", 9},
};

string temp = "";
for (char c : numbers) {
temp += c;

if (m.count(temp) > 0) {
answer = answer * 10 + m[temp];
temp = "";
}
}

return answer;
}

0 comments on commit a39cef8

Please sign in to comment.