python合并俩个有序数组
class Solution(object):def merge(self, nums1, m, nums2, n):
"""
:type nums1: List
:type m: int
:type nums2: List
:type n: int
:rtype: None Do not return anything, modify nums1 in-place instead.
"""
list1, list2, list3 = [], [], []
if nums1 == 0:
return nums2
if nums2 == 0:
return nums1
for i in range(m):
list1.append(nums1)
for j in range(n):
list2.append(nums2)
list3 = list1 + list2
return list3.sort()
为什么结果不对呢? 楼主,请回答问题: 你的目标是什么,为什么说你的结果不对,对的结果是什么样的? 力扣题库? 这题以前我在力扣做过,如果是力扣题,那边的官方解答清晰完整,而且很多大神在那边解答百百种,不香吗? jackz007 发表于 2021-11-21 13:53
楼主,请回答问题: 你的目标是什么,为什么说你的结果不对,对的结果是什么样的?
输入:3 3
输出: 应该是: Do not return anything, modify nums1 in-place instead.
翻译:不要返回任何东西,原地修改nums1。
你的程序修改nums1了吗?没有。
页:
[1]