Ruby solution


  • 0
    T
    def title_to_number(s)
        len = s.length
        offset = 64
        num = 0
        s.each_char do |c|
            num += (c.ord - offset)*(26**(len-1))
            len -= 1
        end
        return num
    end
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.