Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

171. Excel Sheet Column Number

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

For example:

A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28 
...

Example 1:

1
2
Input: "A"
Output: 1

Example 2:

1
2
Input: "AB"
Output: 28

Example 3:

1
2
Input: "ZY"
Output: 701

這題在說把英文字母照順序排列計數,因為只有大寫,這題用ord(輸入)-ord(‘A’)+1取得一個字的位數,再在下個字時再加一輪(26),學到了字元用ord取得ascii數值。


如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)

Welcome to my other publishing channels