LeetCode 168. Excel表列名称(Excel Sheet Column Title)
168. Excel表列名称
168. Excel Sheet Column Title
题目描述
给定一个正整数,返回它在 Excel 表中相对应的列名称。
LeetCode168. Excel Sheet Column Title
例如,
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
...
示例 1:
输出: "A"
示例 2:
输出: "AB"
示例 3:
输出: "ZY"
Java 实现
class Solution {
public String convertToTitle(int n) {
StringBuilder res = new StringBuilder();
while (n > 0) {
n--;
res.insert(0, (char) (n % 26 + 'A'));
n = n / 26;
}
return res.toString();
}
}
相似题目
参考资料
- https://leetcode.com/problems/excel-sheet-column-title/
- https://leetcode-cn.com/problems/excel-sheet-column-title/
LeetCode 168. Excel表列名称(Excel Sheet Column Title)的更多相关文章
- [Swift]LeetCode168. Excel表列名称 | Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...
- 力扣(LeetCode)Excel表列名称 个人题解
给定一个正整数,返回它在 Excel 表中相对应的列名称. 例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> ...
- [LeetCode]题解(python):118-Excel Sheet Column Title
题目来源 https://leetcode.com/problems/excel-sheet-column-title/ Given a positive integer, return its co ...
- Excel表列名称(给定一个正整数,返回它在 Excel 表中相对应的列名称。)
例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB ... 示例 1: 输入: 1 输出: "A ...
- LeetCode 171. Excel表列序号(Excel Sheet Column Number) 22
171. Excel表列序号 171. Excel Sheet Column Number 题目描述 给定一个 Excel 表格中的列名称,返回其相应的列序号. 每日一算法2019/5/25Day 2 ...
- 【LeetCode】168 & 171- Excel Sheet Column Title & Excel Sheet Column Number
168 - Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...
- 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number
题目描述: Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...
- 【leetcode】Excel Sheet Column Title
Excel Sheet Column Title Given a non-zero positive integer, return its corresponding column title as ...
- 168. Excel Sheet Column Title
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...
随机推荐
- Cayley-Hamilton定理与矩阵快速幂优化、常系数线性递推优化
原文链接www.cnblogs.com/zhouzhendong/p/Cayley-Hamilton.html Cayley-Hamilton定理与矩阵快速幂优化.常系数线性递推优化 引入 在开始本文 ...
- 【Vue.js游戏机实战】- Vue.js实现九宫格水果机抽奖游戏总结
大家好!先上图看看本次案例的整体效果. 完整版实战课程附源码:[Vue.js游戏机实战]- Vue.js实现九宫格水果机抽奖 实现思路: Vue component实现九宫格水果机组件,可以嵌套到任意 ...
- Android Mboot mmc命令介绍
mmc command. 目前Mboot支持以下mmc命令: 1) mmc read/write. 读写命令.Addr = 内存地址, blk# = 起始block数, size ...
- 表观 | Enhancer | ChIP-seq | 转录因子 | 数据库专题
需要长期更新! 参考:生信修炼手册 enhancer的基本概念: 长度几十到几千bp,作用是提高靶基因活性,属于顺式作用原件,DNA作用到DNA,转录因子就是反式,是结合到DNA的蛋白. 1981年, ...
- chrome 等浏览器不支持本地ajax请求,的问题
XMLHttpRequest cannot load file:///D:/WWW/angularlx/ui-router-test/template/content.html. Cross orig ...
- Flutter -------- Drawer侧滑
侧滑菜单在安卓App里面非常常见 抽屉通常与Scaffold.drawer属性一起使用.抽屉的子项通常是ListView,其第一个子项是DrawerHeader ,它显示有关当前用户的状态信息.其余的 ...
- PostgreSQL 登录时在命令行中输入密码
有时候需要设置定时任务直接执行 sql 语句,但是 postgresql 默认需要人工输入密码,以下命令可以直接在命令行中直接填入密码 PGPASSWORD=pass1234 psql -U MyUs ...
- VPB测试 使用Osgdem运行例子
1.Osgdem运行例子所需数据下载地址: http://www.cc.gatech.edu/projects/large_models/ps.html Download Elevation Map: ...
- Spring cloud微服务安全实战-4-5搭建OAuth2认证服务器
现在可以访问我们的认证服务器,应用我们已经配置好了. 下面配置让用户可以访问我的认证服务器.再来重写一个方法. EndpointConfigure端点的配置. authenticationManage ...
- Laya的场景以及场景的加载
参考: Laya项目发布详解 Laya2.0 内嵌模式.加载模式.分离模式.文件模式的场景加载创建和场景打开关闭 版本2.1.1.1 白鹭中的场景是exml制作,发布后exml代码都会打包到defau ...