10000 add 171 solution · Mowmowj/leetcode@559899e · GitHub
[go: up one dir, main page]

Skip to content

Commit 559899e

Browse files
committed
add 171 solution
1 parent 48849b0 commit 559899e

File tree

1 file changed

+22
-0
lines changed
  • problems/171. Excel Sheet Column Number

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# 171. Excel Sheet Column Number
2+
3+
## #1 乘膜累加[AC]
4+
5+
### 算法
6+
7+
```java
8+
class Solution {
9+
public int titleToNumber(String s) {
10+
if(s == null || s.length() == 0)
11+
return 0;
12+
int power = 1;
13+
int res = 0;
14+
for(int i=s.length()-1; i>=0; i--){
15+
res += ((s.charAt(i) - 'A' + 1)*power);
16+
power *= 26;
17+
}
18+
return res;
19+
}
20+
}
21+
```
22+

0 commit comments

Comments
 (0)
0