题解 | #合并两个有序的数组#
合并两个有序的数组
https://www.nowcoder.com/practice/89865d4375634fc484f3a24b7fe65665
# # # @param A int整型一维数组 # @param B int整型一维数组 # @return void # class Solution: def merge(self , A, m, B, n): # write code here idx = -1 while m or n: if m and n: if A[m-1]>B[n-1]: A[idx] = A[m-1] m-=1 else: A[idx] = B[n - 1] n -= 1 elif m==0: A[idx] = B[n-1] n-=1 elif n ==0: A[idx] = A[m-1] m-=1 idx-=1