Skip to main content
Back to problems
Leetcode
Easy
Math
Strings
Excel Sheet Column Number

Convert an Excel-style column label like A, Z, AA, or FXSHRXW into its corresponding column number.

Acceptance 100%
Problem Statement

Problem

You are given a string columnTitle that represents an Excel column title.

Excel columns are labeled using uppercase letters starting from A:

  • A = 1
  • B = 2
  • ...
  • Z = 26
  • AA = 27
  • AB = 28

Your task is to return the numeric column index represented by the title.

Treat the title as a base-26 number where A maps to 1 and Z maps to 26, rather than 0 to 25.

Notes

  • The input contains only uppercase English letters.
  • The answer fits in a 32-bit signed integer for standard interview constraints.

Input Format

  • A single string columnTitle.
  • columnTitle consists only of uppercase letters A to Z.

Output Format

  • Return a single integer: the Excel column number for columnTitle.

Constraints

  • 1columnTitle1 \le |columnTitle|
  • columnTitle contains only uppercase letters A-Z
  • The result fits in a signed 32-bit integer
Examples
Sample cases returned by the problem API.

Example 1

Input

columnTitle = "A"

Output

1

Explanation

A corresponds to 1.

Example 2

Input

columnTitle = "AB"

Output

28

Explanation

AB = 1 × 26 + 2 = 28.

Show 1 more example

Example 3

Input

columnTitle = "ZY"

Output

701

Explanation

ZY = 26 × 26 + 25 = 701.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.