Skip to content

Commit 31d4c88

Browse files
committed
Second method for Adding digits.
1 parent b19cfec commit 31d4c88

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Easy/258.Add Digits.playground/Contents.swift

+4
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ class Solution {
3939
}
4040
return res
4141
}
42+
43+
func addDigits2(_ num: Int) -> Int {
44+
return num == 0 ? 0 : (num - 1) % 9 + 1
45+
}
4246
}

0 commit comments

Comments
 (0)