Created
December 20, 2012 18:28
-
-
Save henteko/4347515 to your computer and use it in GitHub Desktop.
SRM565 250
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
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