Skip to content

Commit 55315c6

Browse files
refactor 171
1 parent d0c8c0b commit 55315c6

File tree

1 file changed

+10
-26
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+10
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 170. Two Sum III - Data structure design
5-
*
6-
* Given a column title as appear in an Excel sheet, return its corresponding column number.
7-
8-
For example:
9-
10-
A -> 1
11-
B -> 2
12-
C -> 3
13-
...
14-
Z -> 26
15-
AA -> 27
16-
AB -> 28
17-
18-
*/
193
public class _171 {
204

21-
public static class Solution1 {
22-
public int titleToNumber(String s) {
23-
char[] c = s.toCharArray();
24-
int result = 0;
25-
for (int i = s.length() - 1; i >= 0; i--) {
26-
result +=
27-
(c[i] - 64) * ((int) Math.pow(26, s.length() - i - 1));//The ASCII value of A is 65
28-
}
29-
return result;
5+
public static class Solution1 {
6+
public int titleToNumber(String s) {
7+
char[] c = s.toCharArray();
8+
int result = 0;
9+
for (int i = s.length() - 1; i >= 0; i--) {
10+
result +=
11+
(c[i] - 64) * ((int) Math.pow(26, s.length() - i - 1));//The ASCII value of A is 65
12+
}
13+
return result;
14+
}
3015
}
31-
}
3216
}

0 commit comments

Comments
 (0)