File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ them with C++ Language.
2323| 174 | [ Dungeon Game] | |
2424| 173 | [ Binary Search Tree Iterator] | |
2525| 172 | [ Factorial Trailing Zeroes] | [ C] ( src/172.c ) |
26- | 171 | [ Excel Sheet Column Number] | |
26+ | 171 | [ Excel Sheet Column Number] | [ C ] ( src/171.c ) |
2727| 170 | [ Two Sum III - Data structure design] | |
2828| 169 | [ Majority Element] | [ C] ( src/169.c ) |
2929| 168 | [ Excel Sheet Column Title] | [ C] ( src/168.c ) |
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <string.h>
3+
4+ int titleToNumber (char * s ) {
5+ int len = strlen (s );
6+ int i = 0 ;
7+ int ans = 0 ;
8+ while (i < len ) {
9+ ans = ans * 26 + s [i ] - 'A' + 1 ;
10+ i ++ ;
11+ }
12+
13+ return ans ;
14+ }
15+
16+ int main () {
17+ char s1 [] = "Z" ;
18+ char s2 [] = "AB" ;
19+
20+ printf ("%d\n" , titleToNumber (s1 ));
21+ printf ("%d\n" , titleToNumber (s2 ));
22+ return 0 ;
23+ }
You can’t perform that action at this time.
0 commit comments