rustgym/leetcode/
_168_excel_sheet_column_title.rs

1struct Solution;
2
3impl Solution {
4    fn convert_to_title(mut n: i32) -> String {
5        let mut v: Vec<char> = vec![];
6        while n > 0 {
7            let x = ((n - 1) % 26) as u8;
8            let c = (x + b'A') as char;
9            v.insert(0, c);
10            n = (n - 1) / 26;
11        }
12        v.iter().collect()
13    }
14}
15
16#[test]
17fn test() {
18    assert_eq!(Solution::convert_to_title(701), "ZY".to_string());
19}