# Given two numbers represented as strings,
# return multiplication of the numbers as a string.
#
# Note: The numbers can be arbitrarily large and are non-negative.
class Solution():
def multiply(self, x1, x2):
x1, x2, res = x1[::-1], x2[::-1], [0]*(len(x1) + len(x2))
for i in range(len(x1)):
for j in range(len(x2)):
res[i + j] += int(x1[i]) * int(x2[j])
res[i + j + 1] += res[i + j] // 10
res[i + j] %= 10
i = len(res) - 1
while i > 0 and res[i] == 0:
i -= 1
return ''.join(map(str, res[i::-1]))
if __name__ == "__main__":
assert Solution().multiply("123", "1000") == '123000'