Skip to content

Commit f46021e

Browse files
committed
Create file
1 parent 9298be0 commit f46021e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use std::collections::VecDeque;
2+
3+
const ABC_LEN: i32 = (b'Z' - b'A' + 1) as i32;
4+
5+
impl Solution {
6+
pub fn convert_to_title(column_number: i32) -> String {
7+
let mut column_number = column_number - 1;
8+
let mut result = VecDeque::with_capacity(7);
9+
while column_number >= 0 {
10+
let letter = (column_number % ABC_LEN) as u8 + b'A';
11+
result.push_front(letter);
12+
column_number = column_number / ABC_LEN - 1;
13+
}
14+
unsafe{String::from_utf8_unchecked(result.into())}
15+
}
16+
}

0 commit comments

Comments
 (0)