leetcode中 Merge Sorted Array问题

##问题描述

Given two sorted integer arrays A and B, merge B into A as one sorted array.

Note:
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. The number of elements initialized in A and B are m and n respectively.


##问题分析

该问题比较简单
即数组合并的问题,其中A数组长度为m+n


##c++代码
class Solution {
public:
void merge(int A[], int m, int B[], int n) {
int i = m - 1;
int j;
for(j = n - 1; j>=0; j–){
while((A[i] > B[j]) && i >= 0 ){
A[i + j + 1] = A[i];
i–;
}
A[i + j + 1] = B[j];
}
}

};