本文共 1049 字,大约阅读时间需要 3 分钟。
// Author : yqtao// Date : 2016-7-6// Email : yqtao@whu.edu.cn/************************************************************************************ 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.***********************************************************************************/#include#include using namespace std;//Solutins 1: 4msvoid merge(vector & nums1, int m, vector & nums2, int n) { int i = 0, j = 0, k = 0; vector temp(nums1.begin(), nums1.end()); //using a vector to restore nums1, while (i
转载地址:http://jpdoi.baihongyu.com/