Skip to content

Commit 526522f

Browse files
authored
Update excel-sheet-column-number.py
1 parent 18b9a0e commit 526522f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Time: O(n)
22
# Space: O(1)
3-
#
3+
44
# Related to question Excel Sheet Column Title
55
#
66
# Given a column title as appear in an Excel sheet, return its corresponding column number.
@@ -14,17 +14,19 @@
1414
# Z -> 26
1515
# AA -> 27
1616
# AB -> 28
17-
#
1817

19-
class Solution:
20-
# @param s, a string
21-
# @return an integer
18+
class Solution(object):
2219
def titleToNumber(self, s):
20+
"""
21+
:type s: str
22+
:rtype: int
23+
"""
2324
result = 0
2425
for i in xrange(len(s)):
2526
result *= 26
2627
result += ord(s[i]) - ord('A') + 1
2728
return result
2829

30+
2931
if __name__ == "__main__":
30-
print Solution().titleToNumber("AAAB")
32+
print Solution().titleToNumber("AAAB")

0 commit comments

Comments
 (0)