💡
LeetCode
  • Introduction
  • 1. Two Sum
  • 3. Longest Substring Without Repeating Characters
  • 5. Longest Palindromic Substring
  • 7. Reverse Integer
  • 14. Longest Common Prefix
  • 15. 3Sum
  • 19. Remove Nth Node From End of List
  • 20. Valid Parentheses
  • 31. Next Permutation
  • 46. Permutations
  • 48. Rotate Image
  • 49. Group Anagrams
  • 53. Maximum Sum Subarray
  • 66. Plus One
  • 73. Set Matrix Zeroes
  • 83. Remove Duplicates from Sorted List
  • 121. Best Time to Buy and Sell Stock
  • 122. Best Time to Buy and Sell Stock II
  • 152. Maximum Product Subarray
  • 155. Min Stack
  • 169. Majority Element
  • 171. Excel Sheet Column Number
  • 198. House Robber
  • 200. Number of Islands
  • 217. Contains Duplicate
  • 229. Majority Element II
  • 238. Product of Array Except Self
  • 371. Sum of Two Integers
  • 443. String Compression
  • 525. Contiguous Array
  • 678. Valid Parenthesis String
  • 796. Rotate String
  • 844. Backspace String Compare
  • 876. Middle of the Linked List
  • 1143. Longest Common Subsequence
  • 1417. Reformat The String
  • 1422. Maximum Score After Splitting a String
  • X. Counting Elements
  • X. Backspace String Compare
  • X. Perform String Shifts
  • May 30Day Challenge
    • 278. First Bad Version
Powered by GitBook
On this page

Was this helpful?

171. Excel Sheet Column Number

Easy

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

😇 Solution

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
Previous169. Majority ElementNext198. House Robber

Last updated 5 years ago

Was this helpful?