Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created March 9, 2015 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/4cc4ce4e45e84178bcca to your computer and use it in GitHub Desktop.
Save ik11235/4cc4ce4e45e84178bcca to your computer and use it in GitHub Desktop.
class ValueOfString {
public:
int findValue(string s) {
int sum=0;
for(int i=0;i<s.size();i++)
{
int cnt=0;
for(int j=0;j<s.size();j++)
{
if(s[i]>=s[j])
cnt++;
}
sum+=(s[i]-'a'+1)*cnt;
}
return sum;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment