Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit55315c6

Browse files
refactor 171
1 parentd0c8c0b commit55315c6

File tree

1 file changed

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

1 file changed

+10
-26
lines changed
Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
packagecom.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
publicclass_171 {
204

21-
publicstaticclassSolution1 {
22-
publicinttitleToNumber(Strings) {
23-
char[]c =s.toCharArray();
24-
intresult =0;
25-
for (inti =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-
returnresult;
5+
publicstaticclassSolution1 {
6+
publicinttitleToNumber(Strings) {
7+
char[]c =s.toCharArray();
8+
intresult =0;
9+
for (inti =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+
returnresult;
14+
}
3015
}
31-
}
3216
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp