Make Unreal REAL.
article thumbnail
Level 0. 배열의 원소 삭제하기

Level 0. 배열의 원소 삭제하기 #include #include #include using namespace std; vector solution(vector arr, vector delete_list) { auto pred = [&delete_list](int num) { return find(delete_list.begin(), delete_list.end(), num) != delete_list.end(); }; arr.erase(remove_if(arr.begin(), arr.end(), pred), arr.end()); return arr; }

article thumbnail
Level 0. 주사위 게임 2

Level 0. 주사위 게임 2 #include #include using namespace std; int solution(int a, int b, int c) { unordered_set uset; uset.emplace(a); uset.emplace(b); uset.emplace(c); if (uset.size() == 3) return (a + b + c); else if (uset.size() == 2) return (a + b + c) * (a*a + b*b + c*c); else return (a + b + c) * (a*a + b*b + c*c) * (a*a*a + b*b*b + c*c*c); }

article thumbnail
Level 0. 간단한 식 계산하기

Level 0. 간단한 식 계산하기 #include #include using namespace std; int solution(string binomial) { istringstream iss(binomial); int a, b; char op; iss >> a >> op >> b; switch (op) { case '+': return a + b; case '-': return a - b; case '*': return a * b; default: return 0; } }

article thumbnail
Level 0. ad 제거하기

Level 0. ad 제거하기 #include #include #include using namespace std; vector solution(vector strArr) { auto new_end = remove_if(strArr.begin(), strArr.end(), [](string& s) { return s.find("ad") != string::npos; }); strArr.erase(new_end, strArr.end()); return strArr; }

article thumbnail
Level 0. 9로 나눈 나머지

Level 0. 9로 나눈 나머지 #include #include using namespace std; int solution(string number) { return accumulate(number.begin(), number.end(), 0, [](int sum, int num) { return sum + num - '0'; }) % 9; }

article thumbnail
Level 0. 문자열 뒤집기

Level 0. 문자열 뒤집기 #include #include using namespace std; string solution(string my_string, int s, int e) { reverse(my_string.begin() + s, my_string.begin() + ++e); return my_string; }

검색 태그