Skip to content

Instantly share code, notes, and snippets.

@qiaoxu123
Created March 11, 2019 13:29
Show Gist options
  • Save qiaoxu123/0f5ee5443195d7d5a75384e002aa57a9 to your computer and use it in GitHub Desktop.
Save qiaoxu123/0f5ee5443195d7d5a75384e002aa57a9 to your computer and use it in GitHub Desktop.
> 非常经典的排序题目,两个数组进行插入排序
//Runtime: 8 ms, faster than 92.35%
//Memory Usage: 9.1 MB, less than 52.67%
class Solution {
public:
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
if(!nums2.empty()){
for(int i = m,j = 0;i < m+n;i++,j++){
nums1[i] = nums2[j];
}
sort(nums1.begin(),nums1.end());
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment