--DAY 23--
Hi, I am going to make #100DaysOfCode Challenge. Everyday I will try solve 1 problem from leetcode or hackerrank. Hope you can go with me until end.
Now let's solve problem today:
Problem: Excel Sheet Column Title
Detail: here
My solution(javascript):
var titleToNumber = function(str) {
let colNum = '0ABCDEFGHIJKLMNOPQRSTUVWXYZ';
str = str.split('');
let result = 0, n = str.length-1;
for(let i=0;i<str.length;i++){
result+=((26**n)*colNum.indexOf(str[i]));
n--;
}
return result;
};
-->If you have better solution or any question, please comment below. I will appreciate.
Top comments (0)