题目
思路
水题,基本技能。
代码
class Solution:
""" @param A: sorted integer array A @param B: sorted integer array B @return: A new sorted integer array """
def mergeSortedArray(self, A, B):
# write your code here
C = []
i = 0; j = 0
lenA = len(A); lenB = len(B)
while i < lenA and j < lenB:
if A[i] < B[j]:
C.append(A[i])
i += 1
else:
C.append(B[j])
j += 1
while i < lenA:
C.append(A[i])
i += 1
while j < lenB:
C.append(B[j])
j += 1
return C