页面顶部 Top
文件:  root - text - article - 2020 - 02 - spreadsheet-column-title.txt.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 201 次阅读, 21050 次搜索 | 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:


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
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 201 次阅读, 21050 次搜索 | 116 个单词 定阅此目录的博客

猜您喜欢...

  1. Number of Ways to Climb Stairs
  2. Daily Interview Problem: Trapping Rainwater
  3. Daily Interview Problem: Min Range Needed to Sort
  4. Top K Frequent words
  5. Absolute Path
  6. Daily Interview Problem: Merge List Of Number Into Ranges
  7. Algorithm Interview: Level Order Traversal of Binary Tree
  8. Daily Interview Problem: Distribute Bonuses
  9. Daily Interview Problem: Min Stack
  10. Daily Interview Problem: Tree Serialization

评论 (0)

    当前页暂时没有评论。


最后更新: October 30 2020 14:21:12 | RSS Subscription
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />