Skip to content

Instantly share code, notes, and snippets.

@momchil-velikov
Last active August 29, 2015 14:00
Show Gist options
  • Save momchil-velikov/11243892 to your computer and use it in GitHub Desktop.
Save momchil-velikov/11243892 to your computer and use it in GitHub Desktop.
#include <unordered_map>
#include <string>
#include <iostream>
void sorted(const std::string &a, const std::string &order) {
std::unordered_map<char, unsigned int> count;
for (auto c : a)
++count[c];
for (auto c: order) {
for (auto i = count[c]; i > 0; --i)
std::cout << c;
}
std::cout << std::endl;
}
int main() {
sorted("hello", "loadeh");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment