Merge Two Sorted Arrays
Merge two given sorted integer array A and B into a new sorted integer array.
Example
A=[1,2,3,4]
B=[2,4,5,6]
return [1,2,2,3,4,4,5,6]
Challenge
How can you optimize your algorithm if one array is very large and the other is very small?
Answer
- 先合并,在排序
one array is very large and the other is very small?
说明两个数很有可能最后pk只剩下大数组,那么就将剩余的大数组直接复制即可