It's a leetcode problem: 168. Excel Sheet Column Title @ https://leetcode.com/problems/excel-sheet-column-title/
The code works fine at my mac,
but got compile error at leetcode:
Line 5: ambiguous use of 'init'
So, please tell me which String.init method does this code call?
String(UnicodeScalar(val))
And how I can solve this issue?
class Solution {
func convertToTitle(n: Int) -> String {
var alphabet = [String]()
var result = ""
alphabet = (UnicodeScalar("A").value...UnicodeScalar("Z").value).map({(val: UInt32) -> String in return String(UnicodeScalar(val)); })
var num = n
while num != 0 {
num -= 1
result = alphabet[num % 26] + result
num /= 26
}
return result
}}