Skip to content

Commit 9316656

Browse files
committed
Create 2605.form-smallest-number-from-two-digit-arrays.py
1 parent 8583a10 commit 9316656

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://leetcode.cn/problems/form-smallest-number-from-two-digit-arrays
2+
3+
4+
class Solution1:
5+
'''
6+
Date: 2023.09.05
7+
Pass/Error/Bug: 1/0/0
8+
执行用时: 40 ms, 在所有 Python3 提交中击败了 81.18% 的用户
9+
内存消耗:15.59 Mb, 在所有 Python3 提交中击败了 62.37% 的用户
10+
'''
11+
def minNumber(self, nums1: List[int], nums2: List[int]) -> int:
12+
m1 = min(nums1)
13+
m2 = min(nums2)
14+
15+
share = set(nums1) & set(nums2)
16+
17+
if m1 > m2:
18+
comb = int(str(m2) + str(m1))
19+
else:
20+
comb = int(str(m1) + str(m2))
21+
22+
if share:
23+
share = min(share)
24+
else:
25+
share = comb
26+
27+
return min(share, comb)

0 commit comments

Comments
 (0)