top of page

Looking to master object-oriented and system design for tech interviews or career growth?

  • Improve your system design and machine coding skills.

  • Study with our helpful resources.

  • Prepare for technical interviews and advance your career.

**We're in beta mode and would love to hear your feedback.

Writer's pictureilluminati

Excel Column Number InterviewBit Solution


Problem Description:

Given a column title A as appears in an Excel sheet, return its corresponding column number.


Problem Constraints

1 <= |A| <= 100

Input Format

First and only argument is string A.

Output Format

Return an integer

Example Input

Input 1:
     1 

Input 2:
     28

Example Output

Output 1:
     "A" 
     
Output 2:
     "AB" 

Example Explanation

Explanation 1:
      1 -> "A" 

Explanation 2:
      A  -> 1
      B -> 2
      C -> 3
      ...
      Z -> 26
      AA -> 27
      AB -> 28 


Approach


This question is about base conversion, just think what would you have done if you have given a binary (base-2) instead of base-26.



Time & Space Complexity:

Time Complexity: O(N) 

- N is the size of the string.

Space Complexity: O(1)

Solution:


Comentarios


bottom of page