当前位置:网站首页>Li Kou daily question - day 43 -168. Name of Excel table column
Li Kou daily question - day 43 -168. Name of Excel table column
2022-07-26 21:51:00 【Chongyou research Sen】
2022.7.26 Did you brush the questions today ?
subject :
Give you an integer columnNumber , Back to it in Excel The name of the corresponding column in the table .
for example :
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
analysis :
Given an integer , Turn it into a string , The rules are similar 26 Hexadecimal conversion .
Ideas : about 10 Turn into the system n Binary problem , You can use the module of complementary sum to calculate . For example, in this question , Take the integer first every time 26 The mold , Get the lowest , Then use the mathematical formula to update the integer .
analysis :
class Solution {
public:
string convertToTitle(int columnNumber) {
string ans;
while (columnNumber > 0) {
int a0 = (columnNumber - 1) % 26 + 1;
ans += a0 - 1 + 'A';
columnNumber = (columnNumber - a0) / 26;
}
reverse(ans.begin(), ans.end());
return ans;
}
};
边栏推荐
- 25 cool interactive charts, one entry plotly
- Supplement - nonlinear programming
- 基于memcache的缓存机制的6个指令
- Isilon 的OneFs常见操作命令(一)
- A new technical director asked me to do an IP territorial function~
- [mysql]substr usage - query the value of specific digits of a field in the table
- 【音视频】ijkplayer播放器参数说明文档
- :active vs :focus
- Basic operation of (C language) files
- 7、 Wechat applet running error: error: illegal appid, invalid appid
猜你喜欢

逻辑漏洞----任意账号注册

Type assertion in typescript
![[MySql]substr用法-查询表的某个字段的具体位数的值](/img/d5/68658ff15f204dc97abfe7c9e6b354.png)
[MySql]substr用法-查询表的某个字段的具体位数的值

CMake 的使用

彻底搞通服务发现的原理和实现

LDAP——实现用户统一登录管理

京东一面:Redis 如何实现库存扣减操作?如何防止商品被超卖?

Content management tools, blue bookmarks are enough

Pytoch uses RNN model to build person name classifier

A friend with a monthly salary of 50000 told me that you were just doing chores
随机推荐
Shrimp Shope takes the commodity list API according to keywords
encodeURI VS encodeURIComponent
逻辑漏洞----任意账号注册
Pbootcms一级栏目下的二级三级栏目高亮
ansible安装及使用
2022年简历石沉大海,别投了,软件测试岗位饱和了....
三星发布1.08亿像素图像传感器ISOCELL Bright HMX,小米将首发
京东一面:Redis 如何实现库存扣减操作?如何防止商品被超卖?
基于memcache的缓存机制的6个指令
FreeRTOS个人笔记-软件定时器
When deploying Flink on a single machine and creating the connection table of oracle19c RAC, the error ora-12505 is reported. Who can help
JDBC summary
Jd.com: how does redis realize inventory deduction? How to prevent goods from being oversold?
Number() VS parseInt()
< button> and < input type=button />
Thorough load balancing
(C语言)浅识#define
Pytorch 使用RNN模型构建人名分类器
Object.getOwnPropertyNames() VS Object.keys()
Technology sharing | do you know the functions of the server interface automated testing and requests library?