```
class Solution {
public:
void merge(int A[], int m, int B[], int n) {
int len = m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < len; j++) {
if (B[i] < A[j]) {
len = m + i + 1;
for (int k = len; k > j; k--) {
A[k] = A[k-1];
}
A[j] = B[i];
break;
}
}
if (len != m + i + 1) {
len = m + i + 1;
A[len-1] = B[i];
}
}
}
};
```