Easy recursive Java solution


  • 1
    G
    public class Solution {
        public String convertToTitle(int n) {
            if (n == 0) {
                return "";
            }
            int div, rem;
            div = (n-1)/26;
            rem = (n-1)%26;
            return convertToTitle(div) + (char)('A'+rem);
        }
    }
    

  • 0
    O

    Nice solution.


Log in to reply
 

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