Easy-题目64:168. Excel Sheet Column Title

转载 2016年05月30日 22:42:10

题目原文:
Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
1 -> A
2 -> B
3 -> C

26 -> Z
27 -> AA
28 -> AB
题目大意:
给一个正整数,求出Excel中对应的列号。
题目分析:
Easy第9题类似,一直模26求余数对应字母即可。需注意余0是一种特殊情况。此时末位为Z。
源码:(language:java)

public class Solution {
    public String convertToTitle(int n) {
        if(n<27)
            return new Character((char) (n+64)).toString();
        else {
            if(n%26!=0)
                return convertToTitle(n/26)+new Character((char) ((n%26)+64)).toString();
            else
                return convertToTitle(n/26-1)+new Character('Z').toString();
        }
    }
}

成绩:
0ms,beats 6.39%,众数0ms,93.61%.

相关文章推荐

[LeetCode]--168. Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For exam...

LeetCode 168. Excel Sheet Column Title 解题报告

题目描述: 168. Excel Sheet Column Title   Given a positive integer, return its corresponding ...

[LeetCode]168.Excel Sheet Column Title

【题目】 Given a positive integer, return its corresponding column title as appear in an Excel sheet. ...

<LeetCode OJ> 171 / 168 Excel Sheet Column Number & Title

171. Excel Sheet Column Number My Submissions Question Total Accepted: 58671 Total Submissions: ...

LeetCode 168 Excel Sheet Column Title(Excel的列向表标题)

翻译给定一个正整数,返回它作为出现在Excel表中的正确列向标题。例如: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> ...
  • NoMasp
  • NoMasp
  • 2016-01-11 19:57
  • 3189

leetcode 之Excel Sheet Column Title

Total Accepted: 9173 Total Submissions: 52899 Given a positive integer, return its corres...

【LeetCode】Excel Sheet Column Title

Excel Sheet Column Title 问题描述见链接。 在这个问题中,其实设计的是类似于二进制、十六进制的一种进位方式,可以认为是二十六进制,然而难点在于A-Z中没有0这个数,也...

[C++]LeetCode: 57 Excel Sheet Column Title

题目: Given a positive integer, return its corresponding column title as appear in an Excel sheet. F...

LeetCode: Excel Sheet Column Title

题目:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For e...

关于LeetCode中Excel Sheet Column Title一题的理解

题目如下: Given a positive integer, return its corresponding column title as appear in an Excel sheet....
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)