1. How I sloved
n is the number of characters to add to the first list. I kept looking for 0 in nums1 and switched it to element in nums2 in order. Then I sorted out nums1.
2. Code
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.
"""
for i in range(n):
nums1[nums1.index(0)] = nums2[i]
nums1.sort()
3. Result
Runtime : 32 ms(89.83%), Memory usage : 14 MB(100.00%) (Runtime can be different by a system even if it is a same code.)