To the Top
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 | 195 Views, 20896 Search Bots | 116 Words

Subscribe to Feed Burner | 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:


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
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 195 Views, 20896 Search Bots | 116 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Given two arrays, write a function to compute their intersection.
  2. Daily Interview Problem: Queue Using Two Stacks
  3. Fibonacci coding
  4. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  5. [Daily Problem] Validate Balanced Parentheses
  6. Algorithm Interview: Level Order Traversal of Binary Tree
  7. Daily Interview Question: Create a Simple Calculator
  8. Algorithm Interview: Determine If Linked List is Palindrome
  9. Find Missing Numbers in an Array
  10. Spreadsheet Column Title

Comments (0)

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />