My simple solution


  • 0
    V
    class Solution {
    public:
        string convertToTitle(int n) {
            string result;
            while( n )
            {
                result.insert( result.begin(), ( n - 1 ) % 26 + 'A' );
                n = ( n - 1 ) / 26;
            }
            return result;
        }
    };

Log in to reply
 

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