MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / titleToNumber

Method titleToNumber

C++/Excel-Sheet-Column-Number.cpp:20–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18class Solution {
19public:
20 int titleToNumber(string s) {
21
22 int power=0, colnum=0;
23
24 while(!s.empty()) {
25
26 colnum += (s[s.size()-1] - 'A' + 1)*pow(26, power);
27 power++;
28 s=s.substr(0, s.size()-1);
29
30 }
31
32 return colnum;
33 }
34};
35
36//Complexity: O(n)

Callers

nothing calls this directly

Calls 1

powFunction · 0.85

Tested by

no test coverage detected