8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8762c94 commit 127aebaCopy full SHA for 127aeba
ExcelSheetColumnNumber.h
@@ -0,0 +1,34 @@
1
+/*
2
+ Author: King, wangjingui@outlook.com
3
+ Date: Dec 28, 2014
4
+ Problem: Excel Sheet Column Number
5
+ Difficulty: Medium
6
+ Source: https://oj.leetcode.com/problems/excel-sheet-column-number/
7
+ Notes:
8
+ Related to question Excel Sheet Column Title
9
+
10
+ Given a column title as appear in an Excel sheet, return its corresponding column number.
11
12
+ For example:
13
14
+ A -> 1
15
+ B -> 2
16
+ C -> 3
17
+ ...
18
+ Z -> 26
19
+ AA -> 27
20
+ AB -> 28
21
22
+ Solution: 1. ...
23
+*/
24
+class Solution {
25
+public:
26
+ int titleToNumber(string s) {
27
+ int res = 0;
28
+ if (s.length() == 0) return 0;
29
+ for (int i = 0; i < s.length(); ++i) {
30
+ res = res * 26 + s[i] - 'A' + 1;
31
+ }
32
+ return res;
33
34
+};
0 commit comments