We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5c7503a commit d7a34e3Copy full SHA for d7a34e3
Python/excel-sheet-column-title.py
@@ -1,6 +1,6 @@
1
# Time: O(logn)
2
# Space: O(1)
3
-#
+
4
# Given a positive integer, return its corresponding column title as appear in an Excel sheet.
5
#
6
# For example:
@@ -12,19 +12,22 @@
12
# 26 -> Z
13
# 27 -> AA
14
# 28 -> AB
15
16
17
-class Solution:
18
- # @return a string
19
- def convertToTitle(self, num):
+class Solution(object):
+ def convertToTitle(self, n):
+ """
+ :type n: int
20
+ :rtype: str
21
22
result, dvd = "", num
23
24
while dvd:
25
result += chr((dvd - 1) % 26 + ord('A'))
26
dvd = (dvd - 1) / 26
27
28
return result[::-1]
-
29
30
31
if __name__ == "__main__":
32
for i in xrange(1, 29):
- print Solution().convertToTitle(i)
33
+ print Solution().convertToTitle(i)
0 commit comments