# 171. Excel Sheet Column Number

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

Credits:Special thanks to @ts for adding this problem and creating all test cases.

## Solution <a href="#solution" id="solution"></a>

```java
public class Solution {
      public int titleToNumber(String s) {
        int result = 0;
        for(Character c: s.toCharArray()) {
            int cur = c - 'A' + 1;
            result = result * 26 + cur;
        }

        return result;
    }
}
```


---

# Agent Instructions: 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://anand-aryan.gitbook.io/leetcode/171.-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.
