leetcode 11

Merge Sorted Array python

class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ n_num1 = [] n_num2 = [] for i in nums1[:m]: n_num1.append(i) for j in nums2: n_num1.append(j) s_list = sorted(n_num1 + n_num2) for x in range(n+m): nums1[x] = s_list[x] 정해진 m,n까지 자르고 그 함수를 합친 후 정렬하는 문제입니다. 더 간단히 하신 분들도 있으니 다른 분들것도 참조하세요.