Skip to content

Instantly share code, notes, and snippets.

@henteko
Created December 20, 2012 18:28
Show Gist options
  • Save henteko/4347515 to your computer and use it in GitHub Desktop.
Save henteko/4347515 to your computer and use it in GitHub Desktop.
SRM565 250
class ValueHistogram {
public:
vector <string> build(vector <int> values) {
vector <string> result;
vector<int> c(10, 0);
vector<string> s(51, "..........");
for(int i=0;i < values.size();i++) {
s[c[values[i]]][values[i]] = 'X';
c[values[i]]++;
}
for(int i=0;i<51;i++) {
if(s[i] != "..........") {
result.push_back(s[i]);
}
}
result.push_back("..........");
for(int i=0,j=result.size()-1; i<j;i++,j--) {
string tmp = result[i];
result[i] = result[j];
result[j] = tmp;
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment