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 number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
2
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
- */
19
3
public class _171 {
20
4
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
+ }
30
15
}
31
- }
32
16
}
You can’t perform that action at this time.
0 commit comments