3 lines java code , 0 ms


  • 0
    Z

    3 lines java code , 0 ms

    public class Solution {
        public String convertToTitle(int n) {
            if (n <= 26) return (char)('A' + n - 1) + "";
            if (n % 26 != 0) return convertToTitle((n / 26)) + (char)('A' + (n % 26) - 1);
            else return convertToTitle((n / 26) - 1) + "Z";
        }
    }
    

Log in to reply
 

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