Created
March 9, 2015 16:52
-
-
Save ik11235/4cc4ce4e45e84178bcca 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
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