> For the complete documentation index, see [llms.txt](https://hao-fu-1.gitbook.io/oj/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hao-fu-1.gitbook.io/oj/math/jin-zhi-zhuan-huan/excel-sheet-column-number.md).

# Excel Sheet Column Number

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

> Related to question[Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title/)
>
> Given a column title as appear in an Excel sheet, return its corresponding column number.

## Thoughts

26进制转换. 只是每次要多加1因为它要的不是0\~25而是1\~26.

## Code

```
class Solution {
    public int titleToNumber(String s) {
        int sum = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            char c = s.charAt(i);
            sum += Math.pow(26, s.length() - 1 - i) * (c - 'A' + 1);
        }

        return sum;
    }
}
```

## Analysis

时间复杂度O(N), N为字符串长度. 空间O(1).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hao-fu-1.gitbook.io/oj/math/jin-zhi-zhuan-huan/excel-sheet-column-number.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
