-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path43.字符串相乘.py
More file actions
46 lines (45 loc) · 1.04 KB
/
43.字符串相乘.py
File metadata and controls
46 lines (45 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
# @lc app=leetcode.cn id=43 lang=python
#
# [43] 字符串相乘
#
# https://leetcode-cn.com/problems/multiply-strings/description/
#
# algorithms
# Medium (40.50%)
# Likes: 203
# Dislikes: 0
# Total Accepted: 27K
# Total Submissions: 66.6K
# Testcase Example: '"2"\n"3"'
#
# 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。
#
# 示例 1:
#
# 输入: num1 = "2", num2 = "3"
# 输出: "6"
#
# 示例 2:
#
# 输入: num1 = "123", num2 = "456"
# 输出: "56088"
#
# 说明:
#
#
# num1 和 num2 的长度小于110。
# num1 和 num2 只包含数字 0-9。
# num1 和 num2 均不以零开头,除非是数字 0 本身。
# 不能使用任何标准库的大数类型(比如 BigInteger)或直接将输入转换为整数来处理。
#
#
#
class Solution(object):
def multiply(self, num1, num2):
"""
:type num1: str
:type num2: str
:rtype: str
"""
return str(eval(num1+'*'+num2))