leetcode [#168] | GCidea's blog
目录1. 题目2. 解决方案3. 注意事项
题目Given a positive integer, return its corresponding column title as appear in an Excel sheet.
Example:1 -> A2 -> B3 -> C…26 -> Z27 -> AA28 -> AB
解决方案123456789101112131415161718public class Solution { public String convertToTitle(int n) { if(n <= 0) return ""; List<Integer> list = new ArrayList<>(); while(n > 0){ if(n % 26 == 0) { list.add(26); n = n / 26 - 1; } else { list.add(n ...阅读全文
题目Given a positive integer, return its corresponding column title as appear in an Excel sheet.
Example:1 -> A2 -> B3 -> C…26 -> Z27 -> AA28 -> AB
解决方案123456789101112131415161718public class Solution { public String convertToTitle(int n) { if(n <= 0) return ""; List<Integer> list = new ArrayList<>(); while(n > 0){ if(n % 26 == 0) { list.add(26); n = n / 26 - 1; } else { list.add(n ...阅读全文