Created
March 11, 2019 13:29
-
-
Save qiaoxu123/0f5ee5443195d7d5a75384e002aa57a9 to your computer and use it in GitHub Desktop.
> 非常经典的排序题目,两个数组进行插入排序
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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