코테준비 - Excel Sheet Column Number

정상화·2023년 2월 26일

LeetCode

목록 보기
158/222

Excel Sheet Column Number


class Solution {
public:
    int titleToNumber(string columnTitle) {
        int res = 0;
        int exp = 0;
        for (auto it = columnTitle.end() - 1; it >= columnTitle.begin(); it--, exp++) {
            res += ((*it) - 'A' + 1) * pow(26, exp);
        }
        return res;
    }
};
profile
백엔드 희망

0개의 댓글