Skip to content

Commit d8bcc6f

Browse files
committed
updated solution for multiplyStrings
1 parent b2b4b9d commit d8bcc6f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

String/MultiplyStrings.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class MultiplyStrings {
1818
// calculate product for every digit
1919
for (i, char1) in num1.enumerated() {
2020

21-
guard let digit1 = Int(String(char1)) else {
21+
guard let digit1 = char1.wholeNumberValue else {
2222
fatalError("Invalid Input num1")
2323
}
2424

2525
for (j, char2) in num2.enumerated() {
26-
guard let digit2 = Int(String(char2)) else {
26+
guard let digit2 = char2.wholeNumberValue else {
2727
fatalError("Invalid Input num2")
2828
}
2929

@@ -44,7 +44,7 @@ class MultiplyStrings {
4444
}
4545

4646
// trim starting 0s
47-
while !resStr.isEmpty && resStr.first! == "0" {
47+
while resStr.first == "0" {
4848
resStr.removeFirst()
4949
}
5050

0 commit comments

Comments
 (0)