My clean swift solution


  • 0
    L
    class Solution { func plusOne(digits: [Int]) -> [Int] { var tail = digits.count var result = digits while (tail-- != 0) { if result[tail] != 9 { result[tail] += 1 break } else if tail == 0 { result[0] = 1 result.append(0) break } else { result[tail] = 0 } } return result } }
    


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.