给定一个正整数,返回它在 Excel 表中相对应的列名称。

例如,

    1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
...

示例 1:

输入: 1
输出: "A"

示例 2:

输入: 28
输出: "AB"

示例 3:

输入: 701
输出: "ZY"
class Solution {
public String convertToTitle(int n) {
StringBuilder sb = new StringBuilder();
while (n>0) {
n--;
sb.append((char)('A'+n%26));
n = n/26;
}
return sb.reverse().toString();
}
}

LeetCode168.Excel表列名称的更多相关文章

  1. LeetCode 168. Excel表列名称(Excel Sheet Column Title)

    168. Excel表列名称 168. Excel Sheet Column Title 题目描述 给定一个正整数,返回它在 Excel 表中相对应的列名称. LeetCode168. Excel S ...

  2. [LeetCode] 168. Excel Sheet Column Title 求Excel表列名称

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

  3. 【leetcode 简单】第三十九题 Excel表列名称

    给定一个正整数,返回它在 Excel 表中相对应的列名称. 例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> ...

  4. 168 Excel Sheet Column Title Excel表列名称

    给定一个正整数,返回它在Excel表中相对应的列名称.示例:    1 -> A    2 -> B    3 -> C    ...    26 -> Z    27 -&g ...

  5. LeetCode 168. Excel表列名称(Excel Sheet Column Title)

    题目描述 给定一个正整数,返回它在 Excel 表中相对应的列名称. 例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 - ...

  6. leetcode 实现-168.Excel表列名称

    168.Excel表列名称 描述 给定一个正整数,返回它在 Excel 表中相对应的列名称. 例如, 1 -> A 2 -> B 3 -> C … 26 -> Z 27 -&g ...

  7. Java实现 LeetCode 168 Excel表列名称

    168. Excel表列名称 给定一个正整数,返回它在 Excel 表中相对应的列名称. 例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -&g ...

  8. 刷题-力扣-168. Excel表列名称

    168. Excel表列名称 题目链接 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/excel-sheet-column-title 著作权 ...

  9. [LeetCode] Excel Sheet Column Title 求Excel表列名称

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

随机推荐

  1. Copycat - AppendRequest

    对于Command,Configuration都要通过appendEntries的方式,把Entries同步给follower LeaderState.configure /** * Commits ...

  2. eclipse debug模式

    eclipse debug模式 1.怎样在Eclipse中设置断点 方法/步骤 1 首先打开工程项目 2 第一种是,把鼠标移动想要设置断点的行,在行号前面空白地方双击,就会出现断点 3 第二种是,在菜 ...

  3. falsk_蓝图(blueprint)

    蓝图(blueprint) 随着业务代码的增加,将所有代码都放在单个程序文件中,是非常不合适的.这不仅会让代码阅读变得困难,而且会给后期维护带来麻烦. 什么是蓝图 蓝图:用于实现单个应用的视图.模板. ...

  4. xxx污水厂监控网络定点图

  5. java public,default,protected,private区别

    温习一下:https://www.cnblogs.com/ldq2016/p/6872420.html

  6. private static final Logger logger= LoggerFactory.getLogger(WhMainBusi.class);

    LoggerFactory.getLogger(WhMainBusi.class):指定类初始化日志对象,在日志输出的时候,将会打印日志信息所在的类.如: logger.info("日志信息 ...

  7. linux 查看磁盘读写:iostat

    iostat命令用来查看磁盘IO的读写情况,用法如下: 安装iostat命令 [root@mysql ~]# yum install -y sysstat [root@mysql ~]# iostat ...

  8. SQL Server 2016 发送邮件功能

    --1 安装好SQL Server 2016 --2 安装.Net 3.5 由于SQL Server 2016 安装不提示强制安装.NET 3.5 但是还是需要安装,数据库发送邮件会使用.NET 3. ...

  9. Python3学习之路~6.3 类变量 VS 实例变量

    类变量 VS 实例变量 #Author:Zheng Na # 实例里面可以查询.增加.删除.修改实例变量 class Role: # 类名 # 类变量 name = '我是类name' n=1 n_l ...

  10. SELinux介绍

    SELinux概念 安全加强的Linux,早期的Linux系统安全由系统管理员控制.SELinux就是一些安全规则的集合,类似于人类生活中的法律. DAC:   自由访问控制(以前的linux版本) ...