【leetcode❤python】 88. Merge Sorted Array

#-*- coding: UTF-8 -*-
class Solution(object):
    def merge(self, nums1, m, nums2, n):
        """
        :type nums1: List[int]
        :type m: int
        :type nums2: List[int]
        :type n: int
        :rtype: void Do not return anything, modify nums1 in-place instead.
        """
        tag=len(nums1)
        while tag>m:
            nums1.pop()
            tag-=1
        nums1.extend(nums2[0:n])
        nums1.sort()
        return nums1

sol=Solution()
print sol.merge([1,2,3,0,0,0], 3, [2,5,6], 3)

posted @ 2016-11-13 19:18  火金队长  阅读(330)  评论(0编辑  收藏  举报