Excel Sheet Column Number

by atalaykutlay

Solution to Excel Sheet Column Number on Leetcode

Excel Sheet Column Number
1class Solution:
2    def titleToNumber(self, columnTitle: str) -> int:
3        total = 0
4        for left, c in enumerate(reversed(columnTitle)):
5            char_index = (ord(c) - 64)
6            total += ((26)**left) * char_index
7        
8        return total

Share

Share
Video
A cool 10 sec video.
Share
Detailed
Title, description, and syntax highlighted code.
Share
Simple
Syntax highlighted code with gradient background colored presentation.

Comments

It looks like there is no comment for this snippet. Leave the first one!
You need to login to send a comment.

Similar Snippets

Count Number of Texts
Count Number of Texts

Solution to "Count Number of Texts" question on Leetcode.

Language: python12 months ago
Quicksort in Python
Quicksort in Python

An easy quicksort implementation in Python.

Language: python13 months ago
Second Minimum Node In a Binary Tree
Second Minimum Node In a Binary Tree

Solution to "Second Minimum Node In a Binary Tree" on Leetcode.

Language: python11 months ago