题解 | #合并两个有序的数组#
合并两个有序的数组
http://www.nowcoder.com/practice/89865d4375634fc484f3a24b7fe65665
- 思路很简单,把B塞到A里,然后对A进行sort就行
class Solution { public: void merge(int A[], int m, int B[], int n) { int i, j; j = 0; for (i = m; i < m + n; i++) { A[i] = B[j]; j++; } sort(A, A + m + n); } };