C#,first time beats 100%


  • 1
    T
    public string ConvertToTitle(int n) {
                string ss = "ZABCDEFGHIJKLMNOPQRSTUVWXY";
                string res = "";
                while(n>0)
                {
                    res = ss[n % 26] + res;
                    n = (n % 26 == 0) ? (n / 26 - 1) : (n / 26);
                }
                return res;
        }
    

Log in to reply
 

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