> For the complete documentation index, see [llms.txt](https://adit0503.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adit0503.gitbook.io/leetcode/171.-excel-sheet-column-number.md).

# 171. Excel Sheet Column Number

Given a column title as appear in an Excel sheet, return its corresponding column number.

## :innocent: [Solution](https://leetcode.com/problems/excel-sheet-column-number/)

{% tabs %}
{% tab title="O(s)" %}

```python
class Solution:
    def titleToNumber(self, s: str) -> int:
        
        ans = 0
        for i in range(1,len(s)+1):
            ans += (26**(i-1)) * (ord(s[-i])-64)
        return ans
```

{% endtab %}
{% endtabs %}
