My C# solution very easy to understand


  • 0
    K
    public class Solution {
        public int TitleToNumber(string s) {
            int l = s.Length;
            int base1 = 1;
            int result = 0;
            for(int i = l - 1; i >= 0; i--){
                result += ((int)s[i] - 64) * base1;
                base1 *= 26;
            }
            
            return result;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.