解题思路:
(1)双指针
class Solution {
public:
void merge(int A[], int m, int B[], int n) {
vector<int> v;
int i=0,j=0;
while(i<m && j<n) {
if(A[i]<B[j]) {
v.push_back(A[i]);
i++;
} else if(A[i]>B[j]) {
v.push_back(B[j]);
j++;
} else {
v.push_back(A[i]);
v.push_back(B[j]);
i++;
j++;
}
}
while(i<m) {
v.push_back(A[i]);
i++;
}
while(j<n) {
v.push_back(B[j]);
j++;
}
for(int i=0;i<v.size();i++) {
A[i]=v[i];
}
return;
}
};