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 6cffa5b commit cde96dbCopy full SHA for cde96db
171.Excel-Sheet-Column-Number.java
@@ -0,0 +1,24 @@
1
+// https://leetcode.com/problems/excel-sheet-column-number/
2
+//
3
+// algorithms
4
+// Easy (52.25%)
5
+// Total Accepted: 237,025
6
+// Total Submissions: 453,594
7
+// beats 100.0% of java submissions
8
+
9
10
+class Solution {
11
+ public int titleToNumber(String s) {
12
+ char[] chs = s.toCharArray();
13
+ int length = chs.length;
14
15
+ int base = 1, res = 0;
16
+ for (int i = length - 1; i >= 0; i--) {
17
+ int bit = (chs[i] - 'A') + 1;
18
+ res += bit * base;
19
+ base *= 26;
20
+ }
21
22
+ return res;
23
24
+}
0 commit comments