Skip to content

Commit fe25bde

Browse files
171. Excel Sheet Column Number (java)
1 parent 0dd0650 commit fe25bde

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public int titleToNumber(String s) {
3+
char[] cs = s.toCharArray();
4+
int n = 0;
5+
int p = 1;
6+
for (int i = cs.length-1; i >= 0; i--) {
7+
n += (cs[i]-'A'+1)*p;
8+
p *= 26;
9+
}
10+
return n;
11+
}
12+
}

0 commit comments

Comments
 (0)