题目原文:
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.
题目大意:
给出两个用字符串表示的数字,求他们的乘积(用字符串表示)。
数字可以任意大,且是非负数。
题目分析:
python的int是无限精度的,所以直接水过去就行了。
源码:(language:python)
class Solution(object):
def multiply(self, num1, num2):
"""
:type num1: str
:type num2: str
:rtype: str
"""
return str(int(num1)*int(num2))
成绩:
56ms,beats 77.45%,众数52ms,9.18%
cmershen的碎碎念:
java中也可以用biginteger类实现,但好像不是很快。
需记住,python是强类型语言,实现本题的时候必须类型转换!(我以前一直以为脚本语言都是弱类型的)