Link
#include<bits/stdc++.h> using namespace std; class Solution { public: int titleToNumber(string s) { int n=s.length(),ans=0; for(int i=0;i<n;i++) { ans+=(pow(26,n-i-1))*(s[i]-'A'+1); } return ans; } };
Post a Comment
No comments :
Post a Comment