LeetCode 171 Excel Sheet Column Number

标签: 数学类题目 LeetCode 发布于:2022-03-04 23:34:22 编辑于:2022-03-04 23:34:22 浏览量:879

概述

https://leetcode.com/problems/excel-sheet-column-number/

解法

class Solution {
public:
    int titleToNumber(string columnTitle) {
        int ans = 0;
        for (auto c : columnTitle) {
            ans *= 26;
            ans += c - 'A' + 1;
        }
        return ans;
    }
};

未经允许,禁止转载,本文源站链接:https://iamazing.cn/