题解 | #合并两个有序的数组#
合并两个有序的数组
http://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 p = m+n-1 pA = m-1 pB = n-1 curr = 0 for i in range(p, -1, -1): if pB<0: return elif pA<0 or A[pA] < B[pB]: curr = B[pB] pB -= 1 else: curr = A[pA] pA -= 1 A[i] = curr