博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[LeetCode By Python]168. Excel Sheet Column Title
阅读量:4055 次
发布时间:2019-05-25

本文共 460 字,大约阅读时间需要 1 分钟。

题目:

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

解释:其实就是一个重复取余,取模的过程(10进制转换成26进制)

代码:

class Solution(object):    def convertToTitle(self, n):        """        :type n: int        :rtype: str        """        results = ''        while n:            results = chr((n-1)%26+65)+results            n = (n-1)/26        return results

转载地址:http://kkhci.baihongyu.com/

你可能感兴趣的文章
excel 查找一个表的数据在另一个表中是否存在
查看>>
AsyncTask、View.post(Runnable)、ViewTreeObserver三种方式总结frame animation自动启动
查看>>
Android中AsyncTask的简单用法
查看>>
概念区别
查看>>
Jenkins 启动命令
查看>>
通过C++反射实现C++与任意脚本(lua、js等)的交互(二)
查看>>
利用清华镜像站解决pip超时问题
查看>>
微信小程序开发全线记录
查看>>
CCF 分蛋糕
查看>>
解决python2.7中UnicodeEncodeError
查看>>
小谈python 输出
查看>>
python:如何将excel文件转化成CSV格式
查看>>
机器学习实战之决策树(一)
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
Android/Linux 内存监视
查看>>
Android2.1消息应用(Messaging)源码学习笔记
查看>>
Variable property attributes or Modifiers in iOS
查看>>
NSNotificationCenter 用法总结
查看>>