題目:合併兩個排序的整數數組A和B變成一個新的數組。
鏈接:點擊打開鏈接
思路:python超簡單,因爲自帶sort函數,不需要引用模塊就可以使用
代碼:
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
listA=A
listB=B
for i in listA:
listB.append(i)
listB.sort()
return B