LeetCode – 168. Excel Sheet Column Title

題目連結: https://leetcode.com/problems/excel-sheet-column-title/

func convertToTitle(_ columnNumber: Int) -> String {
    var tmp = columnNumber
    let baseVal = UnicodeScalar("A").value
    var result = ""
    while tmp > 0 {
        let val = (tmp - 1) % 26
        result = String(UnicodeScalar(baseVal + UInt32(val))!) + result
        tmp = (tmp - 1) / 26
    }
    return result
}

Ref: https://leetcode.com/problems/excel-sheet-column-title/discuss/51404/Python-solution-with-explanation