File: root - text - article - 2020 - 02 - spreadsheet-column-title.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 602 Views, 26968 Search Bots | 116 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 602 Views, 26968 Search Bots | 116 Words
| Browse | Archive
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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 602 Views, 26968 Search Bots | 116 Words 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
Related Articles
- Find Pythagorean Triplets
- Daily Interview Problem: Look and Say Sequence
- Daily Interview Puzzle: Falling Dominoes
- Absolute Path
- [Daily Problem] Add two numbers as a linked list
- Daily Interview Puzzle: Intersection of Linked Lists
- Reverse a Linked List
- Daily Interview Problem: Largest BST in a Binary Tree
- CPU Utilization
- Print a tree level-by-level, with line-breaks
©2006~2024 SteakOverCooked - 0.00709 Seconds(s) - 2825.898 KB/s - 11 Online Memory: 498.84 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !