Skip to content

Commit 66aef59

Browse files
solves excel sheet column number
1 parent 036eb8f commit 66aef59

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/ExcelSheetColumnNumber.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class ExcelSheetColumnNumber {
2+
public static int titleToNumber(String column) {
3+
int result = 0;
4+
for (int index = column.length() - 1, factor = 1 ; index >= 0 ; index--, factor *= 26) {
5+
result += factor * (column.charAt(index) - 'A' + 1);
6+
}
7+
return result;
8+
}
9+
}

0 commit comments

Comments
 (0)