knakul853

Untitled

Jul 15th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. /**
  2. knakul853
  3. **/
  4. class Solution {
  5. public:
  6.     int titleToNumber(string s) {
  7.        
  8.         int ans = 0;
  9.        
  10.         for( int i=0;i<s.size(); i++ )
  11.         {
  12.             int num = (s[i] - 'A') + 1;
  13.             ans *=26;
  14.             ans += num;
  15.            
  16.         }
  17.        
  18.         return ans;
  19.        
  20.     }
  21. };
Add Comment
Please, Sign In to add comment