golang implementation

func addStrings(num1 string, num2 string) string { maxLen := 0 if len(num1) > len(num2) { maxLen = len(num1) } else { maxLen = len(num2) } ans := make([]byte, maxLen+1) var carry byte for i, j, k := len(num1)-1, len(num2)-1, len(ans)-1; i >= 0 || j >= 0 || carry == 1; i, j, k = i-1, j-1, k-1 { var x byte if i >= 0 { x = num1[i] - '0' } var y byte if j >= 0 { y = num2[j] - '0' } ans[k] = (x+y+carry)%10 + '0' carry = (x + y + carry) / 10 } if ans[0] == 0 { return string(ans[1:]) } return string(ans) }Add Strings