Middle-题目104:43. Multiply Strings

原创 2016年05月31日 19:55:53

题目原文:
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是强类型语言,实现本题的时候必须类型转换!(我以前一直以为脚本语言都是弱类型的)

版权声明:完整版Leetcode题解请出门左转https://github.com/cmershen1/leetcode/tree/master/docs

相关文章推荐

Leetcode43 Multiply Strings

Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as...

LeetCode 43 - Multiply Strings

Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as...
  • ywcpig
  • ywcpig
  • 2016年03月03日 16:00
  • 168

leetCode 43.Multiply Strings(高精度整数相乘) 解题思路和方法

Multiply Strings Given two numbers represented as strings, return multiplication of the numbers a...

Leetcode 43. Multiply Strings

题目描述: Given two numbers represented as strings, return multiplication of the numbers as a string. ...

leetcode 43. Multiply Strings 9大数相差(java实现)

原题: Given two non-negative integers num1 and num2 represented as strings, return the product ...
  • fyy607
  • fyy607
  • 2017年01月06日 16:53
  • 79

【一天一道LeetCode】#43. Multiply Strings

一天一道LeetCode系列(一)题目 Given two numbers represented as strings, return multiplication of the numbers...

[leetcode]43. Multiply Strings@Java

这其实是一道大数相乘问题,类似的题目我之前的博客已经发过了,今天相当于复习一下吧 https://leetcode.com/problems/multiply-strings/#/descr...

LeetCode43——Multiply Strings

LeetCode43——Multiply Strings 题意: 做乘法,两个乘数都是string类型的。 直接string转整型是不行的,因为大数相乘可能溢出。 之前做过类似的大数乘法。其思...

[LeetCode43] Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string. Note: T...
  • sbitswc
  • sbitswc
  • 2014年05月13日 07:03
  • 548

LeetCode_43---Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string. Note: T...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Middle-题目104:43. Multiply Strings
举报原因:
原因补充:

(最多只允许输入30个字)