Simple solution in python

  • 0
    r = 0
    for c in s:
        r *= 26
        r += ord(c) - ord('A') + 1
    return r

    but it seems not efficient enough. How can i improve it?

Log in to reply

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