Created
March 17, 2015 02:58
-
-
Save prehistoricpenguin/ca9c246a8004b682cebb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <set> | |
#include <algorithm> | |
#include <unordered_map> | |
#include <limits> | |
#include <cassert> | |
#include <cmath> | |
#include <cstdio> | |
#include <cstdlib> | |
int main() { | |
std::string org; | |
std::string type; | |
std::cin >> org >> type; | |
auto trans_pred = [](char ch) { return std::toupper(ch); }; | |
std::transform(std::begin(org), std::end(org), std::begin(org), trans_pred); | |
std::transform(std::begin(type), std::end(type), std::begin(type), trans_pred); | |
std::set<char> memed; | |
auto mem_print = [&](char ch) { | |
if (!memed.count(ch)) { | |
std::cout << ch; | |
memed.insert(ch); | |
} | |
}; | |
size_t j = 0; | |
for (size_t i = 0; i < type.size(); ++i, ++j) { | |
if (type[i] != org[j]) { | |
while (type[i] != org[j]) { | |
mem_print(org[j++]); | |
} | |
} | |
} | |
while (j < org.size()) { | |
mem_print(org[j++]); | |
} | |
return 0; | |
} |
Author
prehistoricpenguin
commented
Mar 17, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment