Skip to main content
Back to problems
#168
Easy Algorithms

Excel sheet column title

Math String
45.8% acceptance
Jan 12, 2026
6047
918
Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ...

Solution

Rust
Time O(n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn convert_to_title(mut column_number: i32) -> String {
    let mut result = String::new();
    
    while column_number > 0 {
      column_number -= 1;
      result.insert(0, ('A' as u8 + (column_number % 26) as u8) as char);
      column_number /= 26;
    }
    
    result
  }
}