Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. The number of elements initialized in nums1 and nums2 are m and n respectively.
Subscribe to see which companies asked this question
解题分析:
简单的题目,合并两个list。对此此处的想法就是讲另一个list加到一个list的后面,然后按着大小排序。
# -*- coding:utf-8 -*- __author__ = 'jiuzhang' class Solution(object): def merge(self, nums1, m, nums2, n): nums1[m:m + n] = nums2[:n] nums1.sort()
时间: 2024-10-16 09:53:01