Skip to content

Commit feb1d16

Browse files
committed
add excel sheet column number
1 parent 4fffc85 commit feb1d16

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

excel-sheet-column-number/README.md

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class Solution {
2+
public int titleToNumber(String s) {
3+
char[] S = s.toCharArray();
4+
5+
int n = 0;
6+
7+
int p = 1;
8+
9+
for(int i = S.length - 1; i >= 0; i--){
10+
11+
n += (S[i] - 'A' + 1) * p;
12+
13+
p *= 26;
14+
}
15+
16+
return n;
17+
}
18+
}

excel-sheet-column-number/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: solution
3+
title: Excel Sheet Column Number
4+
date: 2014-12-28 23:03:17+08:00
5+
---
6+
{% assign leetcode_name = {{page.path | remove: '/index.md'}} %}
7+
{% assign leetcode_readme = {{leetcode_name | append: '/README.md' | prepend: '_root/' }} %}
8+
{% include {{leetcode_readme}} %}

0 commit comments

Comments
 (0)