Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. class ValueOfString {
  2. public:
  3. int findValue(string s) {
  4. int sum=0;
  5. for(int i=0;i<s.size();i++)
  6. {
  7. int cnt=0;
  8. for(int j=0;j<s.size();j++)
  9. {
  10. if(s[i]>=s[j])
  11. cnt++;
  12. }
  13. sum+=(s[i]-'a'+1)*cnt;
  14. }
  15. return sum;
  16. }
  17. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement