Skip to content

Commit b6ca38a

Browse files
🎉 Day 10
1 parent 394489b commit b6ca38a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
## Week 2 🚧
1717
1. [Path Sum III](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3417/) ➡️ [CPP Solution](Week2/pathSum.cpp)
1818
2. [Rotting Oranges](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3418/) ➡️ [CPP Solution](Week2/orangesRotting.cpp)
19+
3. [Excel Sheet Column Number](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3419/) ➡️ [CPP Solution](Week2/titleToNumber.cpp)
1920

2021
## Where to find me? 🌟
2122
* [Website](https://akashwho.codes/)

Week2/titleToNumber.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
int titleToNumber(string s) {
4+
int power = 0;
5+
int n = s.size();
6+
int result = 0;
7+
8+
for(int i = n - 1; i >= 0; --i) {
9+
result += (s[i] - 'A' + 1) * (int) pow(26, power++);
10+
}
11+
12+
return result;
13+
}
14+
};

0 commit comments

Comments
 (0)