Leetcode ☞ 171. Excel Sheet Column Number

837 단어
사이트 주소:https://leetcode.com/problems/excel-sheet-column-number/

171. Excel Sheet Column Number

My Submissions
Question
Total Accepted: 66770 
Total Submissions: 165109 
Difficulty: Easy
Related to question Excel Sheet Column Title
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
    A -> 1
    B -> 2
    C -> 3
    ...
    Z -> 26
    AA -> 27
    AB -> 28 

내 AC:
int titleToNumber(char* s) {
    int ans = 0;
    while(*s){
        ans = ans* 26 + (*s++ - 'A' + 1);
    }
    return ans;
}

좋은 웹페이지 즐겨찾기