文件: root - text - article - 2020 - 02 - spreadsheet-column-title.txt.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 571 次阅读, 25785 次搜索 | 116 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 571 次阅读, 25785 次搜索 | 116 个单词
| 浏览 | 博客存档
Hi, here's your problem today. This problem was recently asked by Amazon:
MS Excel column titles have the following pattern: A, B, C, ..., Z, AA, AB, ..., AZ, BA, BB, ..., ZZ, AAA, AAB, ... etc. In other words, column 1 is named "A", column 2 is "B", column 26 is "Z", column 27 is "AA" and so forth. Given a positive integer, find its corresponding column name.
Examples:
Input: 26
Output: Z
Input: 51
Output: AY
Input: 52
Output: AZ
Input: 676
Output: YZ
Input: 702
Output: ZZ
Input: 704
Output: AAB
Here is a starting point:
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 571 次阅读, 25785 次搜索 | 116 个单词 MS Excel column titles have the following pattern: A, B, C, ..., Z, AA, AB, ..., AZ, BA, BB, ..., ZZ, AAA, AAB, ... etc. In other words, column 1 is named "A", column 2 is "B", column 26 is "Z", column 27 is "AA" and so forth. Given a positive integer, find its corresponding column name.
Examples:
Input: 26
Output: Z
Input: 51
Output: AY
Input: 52
Output: AZ
Input: 676
Output: YZ
Input: 702
Output: ZZ
Input: 704
Output: AAB
Here is a starting point:
class Solution:
def convertToTitle(self, n):
# Fill this in.
input1 = 1
input2 = 456976
input3 = 28
print(Solution().convertToTitle(input1))
# A
print(Solution().convertToTitle(input2))
# YYYZ
print(Solution().convertToTitle(input3))
# AB
猜您喜欢...
- Algorithm Interview: Subarray With Target Sum
- [Daily Problem] Angles of a Clock
- Find the non-duplicate number
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
- Daily Interview Problem: Group Words that are Anagrams
- Daily Interview Problem: Merge Overlapping Intervals
- Algorithm Interview: String Compression
- Daily Interview Problem: Running Median
- Daily Interview Problem: Full Binary Tree
- [Daily Problem] Witness of The Tall People
©2006~2024 牛排过熟 - 0.01633 秒 - 3392.969 KB/s - 45 在线 内存: 517.96 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。